Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To close or not to close - is the close tag a danger to my code?

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
US
I just started playing with framework for the very first time and as I navigate around the scripts I notice that none of them have closing tag ( ?> )

I searched for the meaning to this and found that it appears to be a "trend" or a "highly suggested" practice. Some argue that the tag could create a conflict or unexpected results and best is to leave it out and make sure that no extra space is added to script - I do not even know what "extra space" is ... blank spaces? new lines? blank lines?

So, I have tones of PHP scripts that work just fine; all of them with ?> - Need I go through and remove them?

The danger of running a global search and replace is that there are many instances where I have PHP code embedded within the HTML and removing the ?> in those case could really mess things up.

What is your take on this?


--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Hi

SouthBeach said:
- I do not even know what "extra space" is ... blank spaces? new lines? blank lines?
Anything that can mess up the output.

As the output in post cases is just text content, such extra spaces will pass unnoticed. But if the extra spaces get sent out before HTTP headers or mixed in binary content, then you will certainly notice the mess.

Here at the company we not organized closing tag removing campaign for ~15000 files. In new files we not close the last PHP section, and the old files are touched only on need.


Feherke.
feherke.ga
 
yeah, that is what I thought the problem would be, header related as you include files that may push unwanted spaces/characters thus causing a problem. Thanks!

I will follow your practice of "remove" only as I "revise" the scripts - Do not use as I write new scripts!

--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top