FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Nested PHP
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Nested PHP [message #185312 is a reply to message #184821] Mon, 17 March 2014 15:18 Go to previous message
Gabriel is currently offline  Gabriel
Messages: 11
Registered: March 2014
Karma:
Junior Member
On 10/02/2014 20:24, Adrian Tuddenham wrote:
> I am using a php program to generate and download a webpage as an HTML
> file, the HTML file draws its headers and navigation bar from another
> HTML file using some embedded php with an "include" command.
>
> The embedded php doesn't run when the file is downloaded, so the page
> appears in the browser without its headers or navigation.
>
> Is there a way of making the HTML file run the php or do I have to
> tackle this from another angle?
>


Hi Adrian

If you have downloaded the HTML file in your PHP script and stored it as
a variable named $html then you could make sure the PHP contained within
it is executed by running it through the eval() function:

<?php

$html = '' # Downloaded string data
ob_clean();
eval('?>' . $html); # Execute HTML string data that contains PHP

# Capture the HTML file after the PHP in it has been executed.
$output = ob_get_clean();

# Force download of generated HTML to user browser
header('Content-type: text/html');

# Call the file generated.html
header('Content-Disposition: attachment; filename="generated.html"');

echo $output;

Some notes apply, using eval() is extremely dangerous. You should only
use it if... actually you should never use it and find a different way
instead. If you are at all unsure as to what you are doing and the
security implications then you should avoid it. You should also avoid
running any PHP that is downloaded from another site or source over
which you do not have complete and total control. You really need to
take in to account the warning on the PHP site:
http://www.php.net/manual/en/function.eval.php

Cheers

Gabe
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Filling an array with random input doesn't quite work
Next Topic: string length
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 04:04:09 GMT 2024

Total time taken to generate the page: 0.04299 seconds