christofurr Posted July 19, 2007 Share Posted July 19, 2007 When you include a PHP script using the include() function, is the included script supposed to have the HTML opening and closing tags? Page: <html> <body> <?php include("script.php"); ?> </body> </html> Script.php: <html> <body> <?php echo "Hello World!" ?> </body> </html> Or script.php: <?php echo "Hello World! ?> Quote Link to comment Share on other sites More sharing options...
sKunKbad Posted July 19, 2007 Share Posted July 19, 2007 Only if you want them to. For example, if the include is the only HTML on a page, and the rest is all php code than this would be fine. When the actual page is viewed, you don't want to have more than one set of html tags or you will have validation errors. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 19, 2007 Share Posted July 19, 2007 include will simply insert what ever is in that file into the doc at that pointer position in the document. If you want to change out of php to html than you need to have proper tags to do so. there are 3 kinds of includes include() (no error just inserts it) require() (requires the given file and if it can't open it dies) require_once() (same as require, but if that file has been opened will not open again) Quote Link to comment Share on other sites More sharing options...
christofurr Posted July 19, 2007 Author Share Posted July 19, 2007 include will simply insert what ever is in that file into the doc at that pointer position in the document. That's not working for me. When I include a file with PHP commands without opening and closing PHP tags, it outputs the entire script. Still confused, but I'll experiment a little. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.