Hello Derick, I had this problem until I figured out this code:

filewithvars.txt is:
//
Hello my name is $myname.
You can always contact me at $myemail.
// <eof>

The php script is:
<?
          $myname = 'Elias';
          $myemail = '[EMAIL PROTECTED]';
          $t     = 'filewithvars.txt';
          $fp    = fopen($t, 'rb');
          $lines = fread($fp, filesize($t));
          fclose($fp);
          $t = '$t = "' . addcslashes($lines, '"') . '";';
          eval($t);
          $parsed_file = $t;
?>

"Derick Dorner" <[EMAIL PROTECTED]> wrote in message
000e01c13068$0d316ec0$9865fea9@moax01">news:000e01c13068$0d316ec0$9865fea9@moax01...
I have a simple problem, but for some reason I can't figure it out!
I need to read in a string from a short text file, so I do that the normal
way:
/*
// get string from the text file.
$filename = "textfilehere.text";
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize ($filename));
fclose ($fd);
*/

however, this text file contains variables, for example, the first could be:

Hello $variable_here

now when i print out the text file (it really needs to be emailed, but
anyway) the variables are not parsed with the variables from the script, so
instead of printing the contents of $variable_here within that string, it
actually prints "$variable_here".
so, how can i parse a text file read into a string for variables??

any help is appreciated, and thank you very much in advance!

-derick




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to