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

前端 未结 7 719
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:36

    file_get_contents()

    $file = file_get_contents('email_template.php');
    

    Or, if you're insane:

    ob_start();
    include('email_template.php');
    $file = ob_end_flush();
    

提交回复
热议问题