Re: how to assign a parsed file to a variable?
| From: | Zak Greant | Date: | Tue, 27 Jun 2000 01:31:50 +0000 |
| Subject: | Re: how to assign a parsed file to a variable? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3266@lists.php.net to get a copy of this message | ||
At 08:48 AM 6/27/00 +0800, Vboy wrote:
I got several mails asking if I got any replies/solutions for the
following problem that I posted days ago. Regretfully, the answer
is no. So I repost it again and see if it can be done by PHP...
GOAL: 1) parse an external file with PHP+HTML codes
2) assign the result string to a variable instead of displaying
directly on the PHP script
Example follows...
Thank you!
-------- Original Message --------
Subject: eval(...) not printing on browser, but assigning to a variable
Date: Sat, 24 Jun 2000 11:27:52 +0800
From: Vboy <vboy@bigfoot.com>
To: PHP List <php-general@lists.php.net>
Dear all,
-- test.inc (1 line file)--
<?echo "HELLO";?>
--
-- test.php (1 line file)--
$fcontent=file("test.inc");
while ( list($line_num,$line) = each($fcontent) ) {
$msg .= $line;
}
eval("?>$html_msg");
--
It echos "HELLO" on test.php.
However, I do not want the string "HELLO" printing on test.php,
I want it assigned to avariable instead, so I can use it for other
purpose. e.g. as a mail body
How do I accomplish that?
Hi Vboy,
You should be able to do it a couple of ways.
Run the script on the command line:
$data = /usr/local/bin/php -q script_name.php;
- or -
Use fopen and grab the results of the script via the web.
$fp = fopen ('http://www.mysite.com/mypage.php3');
while (! feof ($fp))
$data .= fgets ($fp, 1024);fclose ($fp); hth, Zak Greant Creative Director Nucleus Information Service Inc. "A camel is a horse designed by a committee." - Alex Issigonis (Designer of the Mini)