André Castro André Castro - 6 months ago 56
PHP Question

php - send variables on the fly to new php file

Pressing a button i create a new php file on the fly. This file has a $variable that holds the result of a MYSQL query.
The file as an echo $variable statement that is converted to the value the $variable holds upon creation of the new file.

I do not want this.

What i need is that echo $variable is written in the new file has echo $variable.

An similar example:

$contents = 'Home';
echo $contents;

Is written in the new php created file as:

<?php echo Home; ?>

The $variable holds the value Home. Sadly is the value Home that is passed and not the original statement.

What do i have to do to write in the new file the original statement?

<?php echo $contents; ?>


Please check following code.

$data = '<?php';
$data .= 'echo $contend; ?>';
$h = fopen('file.php','w');