Page 1 of 1

Need HTML output of the PHP file as String

Posted: Wed Sep 17, 2008 2:45 am
by sathishkpm
Dear All,

I am working on the project to convert my web page into PDF file for that I am using dompdf, the dompdf wants the html text as string but my file is in php. Is there any possibility to get the output of the php file as a string format.

for example my code to convert html string into pdf is in 1.php, I need to have the html string as the html output of the 2.php, so is there any way to get the html output of the 2.php in 1.php as string?

Please help me in this regard,

Thanks in advance.

Regards,

Sathish Kumar :-)

Re: Need HTML output of the PHP file as String

Posted: Wed Sep 17, 2008 3:28 am
by adroit
Hi Friend,

You can do this
<?php
ob_start();
include("2.php")
$html = ob_get_contents();
ob_end_clean();

?>

Now the above $html variable will have the 2.php code in html/string format, you can pass this variable to the 1.php or can create any html page with $html variable as page content.

Regards

Re: Need HTML output of the PHP file as String

Posted: Wed Sep 17, 2008 5:18 am
by sathishkpm
Hi adroit,

Thank you so much.. its working very fine..

Thanks a lot once again.

- Sathish :-)