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 #185145 is a reply to message #184821] Sun, 02 March 2014 14:54 Go to previous messageGo to previous message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma:
Senior Member
Adrian Tuddenham, 2014-02-10 21:24:

> 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.

PHP is only executed on the *server*. Any PHP which is "dynamically"
added as output will *not* be executed at all.

Example - if you have a file "test.php" and request it using the browser
via http://mydomain.example/test.php:

<?php
echo "Test";
?>

This will just output "Test".

BUT: If the same will adds additional PHP code it will just be sent to
the browser without any interpetation by the PHP runtime:

<?php
echo "echo \"My embedded test\";";
?>

If you really need to execute "dynamic" PHP, you have to use eval(),
which executes the code passed as parameter:

<?php
$mycode = "echo \"My embedded test\";";

eval($mycode);
?>

Even though this may work - the problem with eval() is, that it is
horrible to debug. You don't have just a script but a script generating
another script which will then be executed.

I recommend to think about what you want to solve and if it is really
neccessary to create "dyanamic" PHP on the fly.



--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de
[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 00:54:22 GMT 2024

Total time taken to generate the page: 0.04729 seconds