jtorral Posted December 30, 2008 Share Posted December 30, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/138818-help-using-php-tags-inside-html/ Share on other sites More sharing options...
kenrbnsn Posted December 30, 2008 Share Posted December 30, 2008 The value should be there. All PHP code is executed first and the PHP processor will ignore anything it doesn't understand. We need to see some code before we can help you. Please post it between tags. Ken Quote Link to comment https://forums.phpfreaks.com/topic/138818-help-using-php-tags-inside-html/#findComment-725882 Share on other sites More sharing options...
ucffool Posted December 30, 2008 Share Posted December 30, 2008 As Ken said, you can go in and out of html and php and not lose out on anything. So if you have: <?php $world = 'World!'; ?> <html> <p>Hello World!</p> <p>Hello <?php echo $world; ?></p> It will work perfectly fine. Quote Link to comment https://forums.phpfreaks.com/topic/138818-help-using-php-tags-inside-html/#findComment-725884 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.