Using PHP code to load further PHP code from a file
Posted: Sat Apr 24, 2010 4:21 am
Hi,
I new to the whole concept of php and i want to build a dynamic web page.
I'm using conditional coding to load external files containing html and php code.
I would load the file into an array and then echo the array. This works fine for
the html code in the file but, the php code just gets ignored by the server.
e.g.
The file test.php contains the following:
<h1> Hello World </h1><br>
<?php echo 'Hello World' ?>
this is an extract of index.php :
$file_1 = '/var/www/test.php';
$data_1 = file_get_contents($file_1);
echo $data_1;
then both
Hello World
and
<?php echo 'Hello World' ?>
gets passed to the browser without the php code being parsed to the server.
Any Ideas?
Thanks
I new to the whole concept of php and i want to build a dynamic web page.
I'm using conditional coding to load external files containing html and php code.
I would load the file into an array and then echo the array. This works fine for
the html code in the file but, the php code just gets ignored by the server.
e.g.
The file test.php contains the following:
<h1> Hello World </h1><br>
<?php echo 'Hello World' ?>
this is an extract of index.php :
$file_1 = '/var/www/test.php';
$data_1 = file_get_contents($file_1);
echo $data_1;
then both
Hello World
and
<?php echo 'Hello World' ?>
gets passed to the browser without the php code being parsed to the server.
Any Ideas?
Thanks