Saw a thread about closing exception ?> In PHP scripts and made me wonder.
Take this code:
foo.php
<?php echo 'This is foo.php'; include('bar.php');
bar.php
<?php echo 'This is bar.php';
If you create these two scripts and run them, php outputs:
This is foo.php This is bar.php
(new line added for art license before anyone points this out)
So, how did it turn out: baz.php
<?php echo 'This is foo.php'; <?php echo 'This is bar.php';
leads to a predictable syntax error of unexpected '<' when "include" does just that - or rather, my understanding of inclusion is that PHP just uploads the file at that moment, as if it were always there.
Does PHP check for opening tags and ignoring future tags if the file is included? Why not do it when there are two sets of tags in one script?
Thanks for any clarification. Not really an important issue, but it would be nice to understand PHP a little more.
include php tags
Ross
source share