Forum Moderators: coopster

Message Too Old, No Replies

Display my rendered out PHP in an HTML file

php to html to pdf

         

hey suburbia

8:56 pm on Feb 24, 2009 (gmt 0)

10+ Year Member



Here is what I am trying to accomplish.

I have a PHP that generates a page with a .php extension.

I want to take that output .php page and display it in an .html file.

For instance: when you view the source on the php file you see all the html that was created by the php page and not the php code in the php file. I need the new html file to contain nothing but html no php.

I hope that makes sense...

My dilemma is such:

My client wants this page to generate a PDF, Their server doesn't have PHP 5+ (or else I'd just use dompdf...), so what I'm doing is just using a 3rd party html to PDF converter. It works great, but since I'm sending it a php page it tries to parse the PDF content and you get errors.

mack

9:34 pm on Feb 24, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You can set the server to handle php within html files using htaccess. I'm not sure how effective this would be because the app you are using will still effectivly need to work with a php file, even if it is named .html

It may be worth speaking to the host to see about a php5 upgrade. This would certainly make things easier.

The main issue I see with converting php to html is that every page address and every link would change. This could be a maintenance headache and may cause a short term drop in se traffic.

Mack.

hey suburbia

9:52 pm on Feb 24, 2009 (gmt 0)

10+ Year Member



Thanks for the reply, but I think I may be unclear.

I know how to allow html files to run php code, but I want the html file to be free of php code. I'm trying to generate a static html page from a php file. I think it's easier then I'm making it sound.

In a simple breakdown:

Take the html that my .php page creates and generate a new .html page. The new .html page should not have any code in it, just the output.

penders

10:44 pm on Feb 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Are you wanting to use Output Buffering [uk2.php.net] to control output? You could grab the output from your PHP script/page and save this as a static HTML file (or pass it straight to something else)? Is that the sort of thing you mean?

g1smd

10:52 pm on Feb 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



*** Take the html that my .php page creates and generate a new .html page. The new .html page should not have any code in it, just the output. ***

If you simply let the browser access the .php URL then it will not have any PHP code in it. The purpose of the PHP script is to send a page of HTML to the browser. You can only see PHP code in the file if you use FTP to get at the source file. From the browser you will never see PHP code, because the PHP is actually "run" by the server to make a page of HTML.

If you want the user to be using .html URLs to see this content, then either
- set the server up so that .html files are parsed for PHP scripts, or
- set up a a server-internal rewrite so that users use .html URLs, but the server gets the content from the output of the .php script.

phranque

10:56 pm on Feb 24, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you could write a script to make HTTP Requests of you php pages and store the reulting documents in html files.
however you may have problems with internal linking if you don't modify all the urls to refer to the html version instead of the php version.
(or you could handle all that php-to-html url translation with internal rewrites.)