mkosmosports Posted October 4, 2007 Share Posted October 4, 2007 Hi everyone, I must of missed something when I first started learning php, as I was sure I can display html in a .php file outside of the php tags. I dont seem to be able to though! I guess my other two options are echoing out the html from the .php file or setting up apache to parse html files for php as well and making the files .html. What seems like the most server-friendly option? Any advice is welcome. Thanks. mkosmosports Quote Link to comment https://forums.phpfreaks.com/topic/71834-optimal-way-of-combining-php-and-html/ Share on other sites More sharing options...
pocobueno1388 Posted October 4, 2007 Share Posted October 4, 2007 Yes, you can use HTML outside of PHP tags. Could you show us the code thats not working for you? Here is a quick example <?php echo 'blah blah blah'; ?> Now I can put whatever I want outside the PHP tags. Except for PHP code of course xD <?php echo "Now we are back into PHP mode..."; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71834-optimal-way-of-combining-php-and-html/#findComment-361790 Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 I was sure I can display html in a .php file outside of the php tags. I dont seem to be able to though! What makes you say that? Does this work for you? <html> <head> <title>a test</title> </head> <body> <p><?php echo "Hello from php!"; ?></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/71834-optimal-way-of-combining-php-and-html/#findComment-361792 Share on other sites More sharing options...
mkosmosports Posted October 4, 2007 Author Share Posted October 4, 2007 :-\ Dang, Im embarrassed. Of course I can. Thanks pocobueno and thorpe. I think I had a brain freeze there or something. Is this the most server-resources friendly way of combining the two? Quote Link to comment https://forums.phpfreaks.com/topic/71834-optimal-way-of-combining-php-and-html/#findComment-361795 Share on other sites More sharing options...
trq Posted October 4, 2007 Share Posted October 4, 2007 Is this the most server-resources friendly way of combining the two? The difference either way is negligable. Quote Link to comment https://forums.phpfreaks.com/topic/71834-optimal-way-of-combining-php-and-html/#findComment-361808 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.