TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Common short tags (http://www.talkphp.com/general/5093-common-short-tags.html)

h0ly lag 11-07-2009 12:23 AM

Common short tags
 
What are the common PHP short tags? I know of a few such as <?=$str ?>. Actually thats about all I know.

ETbyrne 11-07-2009 03:08 AM

Well you got the loop ones:

PHP Code:

<?php foreach($data as $row): ?>

Something...

<?php endforeach; ?>


delayedinsanity 11-09-2009 10:53 PM

What ETbyrne is referring to is actually called 'alternative conditional structures' and can be highly useful when writing mixed PHP and HTML pages.

As for short tags, the best answer I could give you is to not worry about them. Whatsoever. They're bad coding practice. In addition they almost got wiped out in PHP 6, though it appears they're keeping them for now, with any luck they should be completely gone a few version releases afterwards.

adamdecaf 11-09-2009 11:36 PM

Quote:

Originally Posted by delayedinsanity (Post 29174)
As for short tags, the best answer I could give you is to not worry about them. Whatsoever. They're bad coding practice. In addition they almost got wiped out in PHP 6, though it appears they're keeping them for now, with any luck they should be completely gone a few version releases afterwards.

I really wish that PHP 6 would have taken them out, they are horrible practice.

PHP Code:

<a href="<?php echo $link?>">Click Here!</a>

// vs..

<a href="<?=$link;?>">Click here</a>

It's harder to read the second and more trouble. I was helping someone learn PHP and they were trying to start every script with either <?=php or <?=.

ETbyrne 11-10-2009 01:14 AM

Thanks for the clarification di!

h0ly lag 11-10-2009 06:46 AM

Sorry, that is what I meant originally as well. Alternative conditional structures.


All times are GMT. The time now is 09:35 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0