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));
          $t = '$t = "' . addcslashes($lines, '"') . '";';
          $parsed_file = $t;

"Derick Dorner" <[EMAIL PROTECTED]> wrote in message
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
// 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!


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