At 05:46 03.03.2003, Paul Cohen said:
--------------------[snip]--------------------
>Here is the code in my file and was taken directly from the manual:
>
>    $filename = "test.php";
>    $handle = fopen ($filename, "r");
>    $contents = fread ($handle, filesize ($filename));
>    fclose ($handle);
>    echo $contents;
--------------------[snip]-------------------- 

You need to eval your code (not "exec"):
    eval($contents);

Note that $contents need to be valid PHP for eval(). It must not start with
"<?php" since eval assumes it is code anyway. Some examples:

A) HTML with PHP interspersed
    <b>Some HTML</b><br /><?php echo date('Y'); ?>Blah
you should
    eval("?>$contents<?php");

B) Plain PHP
    echo date('Y');
you should
    eval($contents);

C) "Incomplete" PHP (missing semicolon)
    call_this_function(blah)
you should
    eval("$contents;");

If the PHP code returns some value, this will be the return of eval:
    $contents="return time();";
    $t = eval($contents);

You get the idea.


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to