Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract the raw PHP code from HTML page

Status
Not open for further replies.

prince

Programmer
Apr 18, 2001
2
0
0
IN
Hi
i would really appretiate if someone can help me tro find a way wherein i can extract the PHP code from a HTML file


 
Although this isn't a solution, I would go about it using regular expressions to match everything between the PHP delimiters, ie:

<?php

//code in here

?>

It shouldn't be too difficult as there are definite delimiters.

fortytwo
will@hellacool.co.uk
 
Um it's not possible. PHP is a server-side language, so the server parses your code then returns a pure HTML (or javascript whatever depending on what client-side languages you've stuck in as well) file to the web browser, which is all it sees.
 
Yeah, it would have to be done server side so unless you have access to the raw files before they are parsed and sent to the browser you will not be able o view them.

Unless something goes wrong with PHP interpretation ;-)

fortytwo
will@hellacool.co.uk
 
Hehe, like forgeting delimiters or echoing the whole script =]
 
If you want to display the source code of your PHP page, you can use the
Code:
show_source()
function. For example, I created a page called viewsource.php that looks like this:
Code:
<?
$page = $HTTP_GET_VARS[&quot;src&quot;];
if ($page) show_source($page);
else echo &quot;&quot;;
?>
So when you enter you get the source code for search.php, color-coded and everything!

This requires PHP4 as far as I've heard. Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top