denoteone Posted March 7, 2008 Share Posted March 7, 2008 why if the page is a .PHP file would the file look like <?PHP <?PHP session_start(); session_destroy(); ?> <?PHP print "html output"; print "more html output"; ?> why if it is all php is the page broken up by multiple php tags. I know I should probably know this.... Link to comment https://forums.phpfreaks.com/topic/94885-newbie-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 7, 2008 Share Posted March 7, 2008 Having multiple opening and closing php tags is just poor programming practice and it leads to other errors, like having white-space output to the browser when there are newlines between one closing tag and the next opening tag... Contiguous php code should have one opening tag and one closing tag. Link to comment https://forums.phpfreaks.com/topic/94885-newbie-question/#findComment-486022 Share on other sites More sharing options...
denoteone Posted March 7, 2008 Author Share Posted March 7, 2008 thanks! Link to comment https://forums.phpfreaks.com/topic/94885-newbie-question/#findComment-486036 Share on other sites More sharing options...
cooldude832 Posted March 7, 2008 Share Posted March 7, 2008 Having multiple opening and closing php tags is just poor programming practice and it leads to other errors, like having white-space output to the browser when there are newlines between one closing tag and the next opening tag... Contiguous php code should have one opening tag and one closing tag. It isn't "poor programing" its a valid technique to writing php and when done properly it is useful. example of valid use <?php session_start(); include('constants.php'); include('shell_top.php'); ?> <h3>Welcome to my site</h3> <p>I thought I take a break from php so I didn't have to escape all my "Quotations"<br />This is perfectly legal</p> <?php echo "Well I'm back in php now because I needed to echo the variable of the date!<br />The Date is :".date("Y/m/d").".</p>"; ?> It is valid to go back in forth like I just showed to make it easier to write. however the following example is very poor writting. <?php session_start(); ?> <?php include('constant.php'); ?> Hi <?php echo "Bye"; ?> Logically it makes no sense to do stuff like this Link to comment https://forums.phpfreaks.com/topic/94885-newbie-question/#findComment-486043 Share on other sites More sharing options...
PFMaBiSmAd Posted March 7, 2008 Share Posted March 7, 2008 I'm guessing that you did not read the original question or my reply very closely. Link to comment https://forums.phpfreaks.com/topic/94885-newbie-question/#findComment-486056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.