Jump to content

Help using php tags inside HTML


jtorral

Recommended Posts

I have done most of my coding using nothing but php and then echoing the html tags like so ..

 

echo "<p>HELLO WORLD</p>";

 

this is fine. But now I am using a tool that generates a lot of html and I would like to just include the tidbits of php within the code as follows:

 

html code

...

...

...

<?php insert some php code then close php tag ?>

...

...

...

more html code

...

...

done with html

 

 

My problem is that if I have a really big chunk of html code I may include a php tag near the top and declare a variable inside of that tag the close the tag. Then, later on in the html code I will insert another php tag, try to reference the variable declared in the earlier php tag above but the value is not retained. How can I keep the value and use it again ?

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/138818-help-using-php-tags-inside-html/
Share on other sites

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.