PHP View Source

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
truepal20032001
Forum Commoner
Posts: 27
Joined: Mon Jun 25, 2007 8:28 pm

PHP View Source

Post by truepal20032001 »

Hello, I want for PHP to look at the source of another PHP file in terms of its HTML output...Meaning that i cannot use fopen() because it will actually get the PHP source, I want it to get the source as if the page were already executed... and all you could get is the HTML source. It is possible to do it fopen() if it was not on my server, but since it is, it grabs the PHP source instead...
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP View Source

Post by onion2k »

You can use fopen() actually. Just remember to use a full URL like "http://www.example.com/path/to/script.php" rather than just script.php. file_get_contents() is probably easier mind you. You'll still need the full path.

In theory you could always get the PHP source and just eval() it too, but that'd be a bit dodgy from a security point of view.
truepal20032001
Forum Commoner
Posts: 27
Joined: Mon Jun 25, 2007 8:28 pm

Re: PHP View Source

Post by truepal20032001 »

onion2k wrote:You can use fopen() actually. Just remember to use a full URL like "http://www.example.com/path/to/script.php" rather than just script.php. file_get_contents() is probably easier mind you. You'll still need the full path.

In theory you could always get the PHP source and just eval() it too, but that'd be a bit dodgy from a security point of view.
I tried ur method also, but it still does the same thing, do you think the only method of doing this is by viewing it through a proxy?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: PHP View Source

Post by omniuni »

I suspect that the problem then may be what you are doing with it. So... what are you trying to do with it? Perhaps you just need to include() the file?

Code: Select all

include('file.php');
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: PHP View Source

Post by califdon »

What you are asking is to parse the file the same way that a web server would parse it. Without doing a LOT of programming, I don't see how you could do that. It might help if you explained why you want to do this.
Post Reply