Jump to content

optimal way of combining php and html..


mkosmosports

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/71834-optimal-way-of-combining-php-and-html/
Share on other sites

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...";

?>

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.