davidf85 Posted February 18, 2012 Share Posted February 18, 2012 How does PHP continuity exist in different php tags? for example, if i connect to a database in a header, and close the tag, can I still work off of the same database in another tag? Quote Link to comment https://forums.phpfreaks.com/topic/257244-php-tags/ Share on other sites More sharing options...
dragon_sa Posted February 18, 2012 Share Posted February 18, 2012 certainly can as long as you dont close the mysql link in the previous tag, its only when you load another page do you need to call the database connection again. Quote Link to comment https://forums.phpfreaks.com/topic/257244-php-tags/#findComment-1318601 Share on other sites More sharing options...
kicken Posted February 18, 2012 Share Posted February 18, 2012 There is no separation of stuff between tags. You can imagine that all the different blocks get squished together into one giant script, and anything that was outside the tags is just turned into an echo. Eg: <?php $db = mysql_connect(); //do stuff ?> <p>echo some <br> html here </p> <?php $q = mysql_query(); //do more stuff ?> is functionally equivilent to: <?php $db = mysql_connect(); //do stuff echo '<p>echo some <br> html here </p> '; $q = mysql_query(); //do more stuff ?> Quote Link to comment https://forums.phpfreaks.com/topic/257244-php-tags/#findComment-1318602 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.