-1

I have the following to read a file and assign to a string:

$insert_html = file_get_contents('view.php');

The view.php file itself looks like:

<div>This is price of your item: <?php echo $price; ?></div>

However, the PHP inside the file is not being executed. Both eval() and include don't quite give me what I want. What is the best way to do this?

MattP
  • 1,785
  • 1
  • 14
  • 21
Guillermo Phillips
  • 2,076
  • 1
  • 21
  • 37

1 Answers1

0

You can use that $insert_html = exec('view.php'); but I don't think it's the best way.

Regards.

elisa
  • 1
  • 2