Jump to content

newbie question


denoteone

Recommended Posts

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
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.

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.