Effect of omitting ?> ?
Moderator: General Moderators
-
Scrumpy.Gums
- Forum Commoner
- Posts: 71
- Joined: Thu Aug 30, 2007 2:57 pm
- Location: Bristol, UK
Effect of omitting ?> ?
A couple of times, I've seen the last close tag ?> being left off of a php script. What effect does this have (providing that there's no following code)?
Re: Effect of omitting ?> ?
It means any whitespace after the closing tag that would break your headers (eg causing a "Headers already sent" error) won't ever be able to break your code again.
In theory it also makes PHP parse the script faster because it doesn't have to check if there's any more PHP after the closing tag. I've never bothered to benchmark it though so that might not actually be true.
For the record, I never put ?> at the end of my code these days.
In theory it also makes PHP parse the script faster because it doesn't have to check if there's any more PHP after the closing tag. I've never bothered to benchmark it though so that might not actually be true.
For the record, I never put ?> at the end of my code these days.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Re: Effect of omitting ?> ?
same here, another useful trick I learned here at DevNet 
There's really no reason to use it unless you have content after your code, in which case you should probably be using templates.... but I digress.
There's really no reason to use it unless you have content after your code, in which case you should probably be using templates.... but I digress.