Jump to content

newbie question


denoteone

Recommended Posts

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

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

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.