I have a bunch of PHP files, from which I want to extract the final HTML result. For example if the PHP file content be something like:
<ul id='<% echo($newsListId) %>'>
// PHP loop to create <li> elements
</ul>
What should be extracted is:
<ul id='news-list'>
<li>First News</li>
<li>Second News</li>
<li>Third News</li>
<li>Fourth News</li>
</ul>
What should I do? Is there a software which can do that for me?
Note: There is no dynamic content in PHP files. In other words, no connection to any external database is made in PHP files. Actually, these PHP files belong to a template I downloaded from somewhere and now I want to change their language to something else (like ASP.NET for example).
It would be easiest to install a local apache on your machine (Like MAMP
or WAMP
), and then build a PHP script that would loop over the folder structure and read each file with file_get_contents()
through the server.
If you try to read myFile.php , you will get the source, But if its parsed through the server first, meaning - reading http://localhost/myFile.php , will returned the parsed result from PHP.
Shai.
run php files on your server in order to get the result, then view source in browser and copy and paste the output
yes, you can echo them into an output buffer (PHP code):
ob_start();
include('your_file.php');
$contents = ob_get_clean();
now $contents
hold the parsed contents of that file and you can write it into another file with:
file_put_contents('filename.html', $contents);
cheers!