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

前端 未结 7 722
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:33

    You have two optional choices

    [Option 1]

    1. Create a file called 'email_template.php'
    2. inside the file add a variable like so

      $body = 'email content here';

    3. in another file require_once 'email_template.php'

    4. then echo $body;

    [Option 2]

    $body = require_once 'email_template.php';
    

提交回复
热议问题