Re: automatically updating software
| From: | Ernest E Vogelsinger | Date: | Mon, 11 Nov 2002 16:34:23 +0000 |
| Subject: | Re: automatically updating software | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123828@lists.php.net to get a copy of this message | ||
At 17:12 11.11.2002, Charles Wiltgen spoke out and said:
--------------------[snip]--------------------
>You could use eval(), but that didn't work for me since I had mixed
>PHP/XHTML.
--------------------[snip]--------------------
Why wouldn't it work?
This works (tested):
<?php
$code = '<html><head><title>ASS - A Simple
Sample</title></head>' .
"\n" .
'<body>' . "\n" .
'<h1>Welcome to ASS</h1>' . "\n" .
'<?php ' . "\n" .
'$i = 4711; ' . "\n" .
'?>' . "\n" .
'The code from PHP is <b>' .
'<?=$i?>' .
'</b>' . "\n" .
'</body></html>';
eval('?>' . $code . '<?php ');
?>
Note that I escape from PHP before and restart PHP after "$code" to emulate
the correct include behavior. Assuming your code is in an external file,
you could (untested):
$fp = fopen('codefile.inc', 'r');
if ($fp) {
$code = fread($fp, filesize('codefile.inc'));
fclose($fp);
eval('?>' . $code . '<?php');
}
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/