How to assign the contents of a file to a variable in PHP

前端 未结 7 668
Happy的楠姐
Happy的楠姐 2020-12-30 07:22

I have a document file containing HTML markup. I want to assign the contents of the entire file to a PHP variable.

I have this line of code:

$body = in

相关标签:
7条回答
  • 2020-12-30 07:54

    Yes you can its easy.

    In the file you want to use the variable place this

    require_once ‘/myfile.php';
    if(isset($responseBody)) {
        echo $responseBody;
        unset($responseBody);
    }    
    

    In the file you are calling /myfile.php place this

    $responseBody = 'Hello world, I am a genius';
    

    Thanks Daniel

    0 讨论(0)
提交回复
热议问题