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

?>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.