Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Short tags and short constructs
Old 06-30-2011, 09:27 AM Short tags and short constructs
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
There has been some minor discussions about short tags recently in other threads, saying that they are bad because of compability issues, in case some script is moved to a server where short tags has been disabled.

I'm just curious, does the short tag setting also include the short constructs like if, else, foreach etc. (which I find very helpful at times)? If you don't know what i'm talking about ('cause I don't really know what they're called) i mean the ability to write like this:

PHP Code:
<?php if($some_var == 'some_value'): ?>
   <p>This is noraml html code</p>
<?php else: ?>
   <p>Hmm, seems some variable doesn't have some value.</p>
<?php endif; ?>

<?php foreach($alphabet as $letter): ?>
   <div>
      <p><?=$letter?> is part of the alphabet!</p>
   </div>
<?php endforeach; ?>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 06-30-2011, 10:26 AM Re: Short tags and short constructs
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Nope!

"Short tags" is using the '<?' opening delimiter instead of the '<?php' full delimiter.

Using the full opening delimiter '<?php' will ensure your script is portable.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-30-2011, 03:25 PM Re: Short tags and short constructs
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
And a quick note: enabling short tags at webserver level to cope with php that uses them just leads to other issues (says he after taking over thousands of lines of legacy code) (and wanting a quick fix).
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 06-30-2011, 04:47 PM Re: Short tags and short constructs
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
At the risk of sounding like a broken record: Short tags are evil!

Even if you aren't writing portable code right now, using short tags is a habit. They have a way of creeping into your code even when you don't mean to use them and the issues they cause aren't always immediately apparent. Take the following code:
PHP Code:
<a href="<?=$link?>">My Link</a>
If you turn short tags off the above code won't generate an error message and you won't even see the raw PHP code when looking at the resulting page.

The alternate syntax for control flow statements is fine to use. Unlike short tags there is no way to disable it so using it doesn't create any compatibility issues.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 06-30-2011 at 04:48 PM..
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-01-2011, 06:56 AM Re: Short tags and short constructs
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Thanks for your answers!
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 07-02-2011, 11:23 AM Re: Short tags and short constructs
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I'm pretty sure that enabled/disabled short tags settings does not affect any type of syntax constructs.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Short tags and short constructs
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23401 seconds with 12 queries