this might seem as an odd question about PHP, but I'm simply asking it because I'm interested in the possibilities of PHP. Okay, here it comes: Is it possible to capture a complete parsed page in a variable. In other words: I want the output of the php parser to be the value of my variable $page.
Example:
snipppet of 'mypage.php?name=Michiel'
<HTML>
<HEAD>
<TITLE>
<?PHP
if (IsSet($name)) print ("Homepage of $name");
else print ("Homepage of anonymous");
?>
</TITLE>
etc. etc.
Now I would like, somehow that the value of my variable $page is gona be:
$page = "<HTML><HEAD><TITLE>Homepage of Michiel</TITLE> etc. etc."
I hope my question is clear enough ;)
Thanx Michiel
not exactly with you but I thnk you mean either this
no this is not exactly what I mean, thanks though for your reply :). I'll try to explain again what is is that I'm looking for:
When you call a php-script in your browser, the php-script is parsed on the server by a php-parser, right? The output of the parser is pure html-code which is displayed by the browser. What I want to do is parse my php-script entirely and then put the output in a variable $page instead of displaying the output in the browser. So then the content of $page would be everything from '<HTML><HEAD> ...... 'til </BODY></HTML>'.
I hope this makes my question a bit more understandable ....
Regards, Michiel
I am wroking on a page as well, and I was looking at this page today. I think that it will help you. It is located at:
This page actually talks about compression, but it might help.
I would think that you could just do this:
$yaks=implode('',file('mypage.php?name=Michiel'));
What firepages said, but this might give you a little more to look at. I don't know, but I hope that it helps.
~evlich
Michiel, have you tried to open an URL with the file() example above? I mean, like
That should retrieve the contents of mypage.php, parsed by the PHP engine and assign the value to the $yaks variable.
fopen wrappers must be enabled for URLs though, see the tip at
http://www.php.net/manual/en/function.file.php
rather than
$yaks=implode(" ",file('http://www.example.org/mypage.php?name=Michiel'));
I personnaly think it would be better to use
$yaks=implode("\n",file('http://www.example.org/mypage.php?name=Michiel'));
Not much change but if ever you come to print $yaks then the page won't appear on a whole line in the page source.
@Flamerule: I thought that was unneccessary, because the manual says:
Identical to readfile(), except that file() returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached
taken from http://za2.php.net/manual/en/function.file.php