Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-02-2002, 10:02 AM   PM User | #1
Michiel
Regular Coder

 
Join Date: Jul 2002
Location: The Netherlands
Posts: 252
Thanks: 0
Thanked 0 Times in 0 Posts
Michiel is an unknown quantity at this point
$page = output of php-parser ???

Hi,

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
Michiel is offline   Reply With Quote
Old 07-02-2002, 01:55 PM   PM User | #2
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
not exactly with you but I thnk you mean either this
PHP Code:
$yaks=implode('',file('mypage.php?name=Michiel')); 
or this ?

PHP Code:
if (IsSet($name)) {
$title="Homepage of $name"); 
}else{
$title"Homepage of anonymous"
}

$str="
<HTML> 
<HEAD> 
<TITLE> 
$title
</TITLE> 
</HEAD><BODY> etc etc
"
;

echo 
$str

either way the answer is yes
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 07-02-2002, 06:12 PM   PM User | #3
Michiel
Regular Coder

 
Join Date: Jul 2002
Location: The Netherlands
Posts: 252
Thanks: 0
Thanked 0 Times in 0 Posts
Michiel is an unknown quantity at this point
Hmm,

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
Michiel is offline   Reply With Quote
Old 07-04-2002, 04:28 AM   PM User | #4
Evlich
New Coder

 
Join Date: Jun 2002
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Evlich is an unknown quantity at this point
Here is a link that might help

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:

http://www.phpbuilder.com/columns/argerich20010125.php3

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
Evlich is offline   Reply With Quote
Old 07-04-2002, 02:42 PM   PM User | #5
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
Michiel, have you tried to open an URL with the file() example above? I mean, like

$yaks=implode('',file('http://www.example.org/mypage.php?name=Michiel'));

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
mordred is offline   Reply With Quote
Old 07-04-2002, 10:24 PM   PM User | #6
Flamerule
New Coder

 
Join Date: Jun 2002
Location: Paris, France
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Flamerule is an unknown quantity at this point
rather than
PHP Code:
$yaks=implode(" ",file('http://www.example.org/mypage.php?name=Michiel')); 
I personnaly think it would be better to use
PHP Code:
$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.
__________________
I don't suffer from insanity, I enjoy every single minute of it!
Flamerule is offline   Reply With Quote
Old 07-04-2002, 11:39 PM   PM User | #7
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
@Flamerule: I thought that was unneccessary, because the manual says:

Quote:
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

mordred is offline   Reply With Quote
Old 07-05-2002, 07:39 AM   PM User | #8
Flamerule
New Coder

 
Join Date: Jun 2002
Location: Paris, France
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Flamerule is an unknown quantity at this point
woups

*hides*
__________________
I don't suffer from insanity, I enjoy every single minute of it!
Flamerule is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:15 AM.


Advertisement
Log in to turn off these ads.