Another newb question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Fusion
Forum Newbie
Posts: 13
Joined: Wed May 12, 2004 9:48 am

Another newb question

Post by Fusion »

so were does the code in a php include get executed...is it like so:

Code: Select all

<div id="Footer">
<?php
$foldersin = 1;
include('../footer.inc') ?>
<img src="<?php echo $pre; ?>images/footer.jpg" alt="" height="107" width="800" border="0">
</div>
</body>
</html>
or like so:

Code: Select all

<div id="Footer">
<?php
$foldersin = 1;
include('../footer.inc')
<img src="<?php echo $pre; ?>images/footer.jpg" alt="" height="107" width="800" border="0">
</div>
</body>
</html>
 ?>
in other words, is my <?php echo $pre; ?> being canceled out by the include because you cant have a php tag inside another?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

The first one
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Try it and see? The 2nd one will give you a syntax error.
Fusion
Forum Newbie
Posts: 13
Joined: Wed May 12, 2004 9:48 am

Post by Fusion »

Try it and see? The 2nd one will give you a syntax error.
I know it gives me a syntax eror, im trying to figure out witch one the server out puts if it did show the php code and HTML. but i am thinking the first one also, thanks a bunch
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You can't have nested php-tags.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

The first one is correct because you jump in and out of PHP in the correct sequence.

The second one you never end your PHP block - you cannot have HTML embedded into your PHP in that manner without either echoing/printing it in some way. Anything between the <? ?> tags must be valid PHP code and "</div>" isn't, for example. Hope that makes more sense.
Post Reply