newbie 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
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

newbie question

Post by 9902468 »

I have pure php in my include file. Do I have to have / is it allowed to have. <?php and ?> tags in my include file? Include code looks like this:

<?php
require_once 'all_fun.php';
?>

And all_fun.php like this

<?php
all_fun_contentshere
?>

If I understand correctly PHP outputs everything from my include file to the place where require_once is called... So the code is effectively like this?

<?php
<?php
all_fun_contentshere
?>
?>

Someone said to me that include files must have those tags too, but i think that they are futile, perhaps even a mistake? What PHP does when it encounters nested php tags?

thanks for the info

-9902468
Peter
Forum Commoner
Posts: 28
Joined: Mon Jun 10, 2002 12:40 am
Location: Brisbane, Australia

Post by Peter »

Included files have to have the <? ?> tags or ASP tags (if enabled) in order to make php parse the files... otherwise it'll just include the file as text. include() and require() don't only include php files... there would be no point in parsing non-PHP files. ;)
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post by 9902468 »

My bad again. yep thanks
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Peter: However, the preferred style is <?php ?>, the full tags. They will always work, as the other two won't.
Post Reply