Page 1 of 1

PHP View Source

Posted: Mon Dec 29, 2008 4:53 pm
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...

Re: PHP View Source

Posted: Mon Dec 29, 2008 5:05 pm
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.

Re: PHP View Source

Posted: Mon Dec 29, 2008 9:33 pm
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?

Re: PHP View Source

Posted: Mon Dec 29, 2008 9:42 pm
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');

Re: PHP View Source

Posted: Tue Dec 30, 2008 1:55 pm
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.