Page 2 of 3
Re: SHort tags
Posted: Sat Feb 14, 2009 2:56 pm
by josh
alternative syntax hurts my head. I recently made the mistake of selling code that had short tags, out of chance I emailed the guy to ask him how he was coming along and he was like "im still replacing all these tags", i was like man... find & replace.
Re: SHort tags
Posted: Sat Feb 14, 2009 4:06 pm
by alex.barylski
Why does alternative syntax hurt your head?
In HTML templates it's way better than standard PHP, no?
Re: SHort tags
Posted: Sat Feb 14, 2009 4:24 pm
by Benjamin
I've never really liked short tags. When you have static XML in your PHP you have to turn off short tags anyway. How would you like to remove all the short tags from every file in a large application just to get one page to work?
Ahhh.. I just think they are ugly anyway. They drive me nuts.
The first thing I think when I see a codebase with short tags is that the programmer was a newbie and inexperienced.
Re: SHort tags
Posted: Sat Feb 14, 2009 4:32 pm
by alex.barylski
he first thing I think when I see a codebase with short tags is that the programmer was a newbie and inexperienced.
While that is usually the case, they are slightly more aesthetically appealing:
<?= $some_var; ?>
compared to
<?php echo $some_var; ?>
So I can understand why people use them in templates as it's nicer to look at inside a alt tag or something similar.
Re: SHort tags
Posted: Sat Feb 14, 2009 4:32 pm
by josh
PCSpectra wrote:In HTML templates it's way better than standard PHP, no?
How, because it reminds you of the 60s?

Re: SHort tags
Posted: Sat Feb 14, 2009 4:48 pm
by Benjamin
Well I think regex is aesthetically appealing
Re: SHort tags
Posted: Sat Feb 14, 2009 5:12 pm
by josh
I agree too, alt syntax reminds me of VB and is ambiguous with the existing syntax tho
Re: SHort tags
Posted: Sat Feb 14, 2009 6:18 pm
by alex.barylski
How, because it reminds you of the 60s?
Considering I wasn't born until 1979...no...not really.
If you don't use alternative syntax, how do you code your HTML templates? Do you use Smarty *gag* or do you use the more obfuscated inline PHP, likeso:
Code: Select all
<div>
<?php
if($a == $b){?>
<strong><?php echo $title; ?></strong>
<?php } ?>
</div>
When compared to:
Code: Select all
<div>
<?php if($a == $b): ?>
<strong><?php echo $title; ?></strong>
<?php endif; ?>
</div>
Not only is it easier on my eyes (especially once you get into complex presentation logic) but IDE's that support code folding will recorgnize the open and close tags and allow you to hide entire sections, using the former syntax, causes all sorts of weird hilighting issues (in some IDE's) not to mention disabling code folding in many instances.
Re: SHort tags
Posted: Sat Feb 14, 2009 6:32 pm
by Eran
Code: Select all
<?php if($a == $b): ?>
<strong><?php echo $title; ?></strong>
<?php endif; ?>
You used long tags in here.. the alternative syntax for control structures is not related to short/long tags. I use the same syntax inside templates
Re: SHort tags
Posted: Sat Feb 14, 2009 6:45 pm
by alex.barylski
I realize that, re-read the discussion and you'll see I said:
Short tags are nice in alternative syntax templates though...
TO which josh replied:
alternative syntax hurts my head.
So I asked why it hurt his head...I don't think either of implied that alternative syntax and short/long tags were the same thing, did we?
EDIT | The point was given the examples I gave above:
Isn't as nice to lok at as:
Re: SHort tags
Posted: Sat Feb 14, 2009 6:51 pm
by Eran
Again, the considerations of portability eliminate short-tags for me. For this reason, almost all external libraries use long-tags - and I don't like mixing too much such conventions. It leads to stupid mistakes and too much headaches.
Re: SHort tags
Posted: Sat Feb 14, 2009 7:00 pm
by josh
PCSpectra wrote:If you don't use alternative syntax, how do you code your HTML templates? Do you use Smarty *gag* or do you use the more obfuscated inline PHP, likeso:
Neither.
Code: Select all
<table>
<tr>
<td colspan="2"></td>
<?php
foreach( $this->grid->getFields() as $field )
{
echo '<td><b>' . ucfirst( $field ) . '</b></td>';
}
?>
</tr>
<?php
foreach( $this->grid->getRows() as $model )
{
?>
<tr>
<td><a href="<?=$this->getEditUrl( $model->getId() )?>">Edit</td>
<td><a href="<?=$this->getDeleteUrl( $model->getId() )?>">Delete</td>
<?php
foreach( $this->grid->getFields() as $field )
{
$command = 'get' . ucfirst( $field );
if( method_exists( $model, $command ) )
{
?>
<td><?=$this->escape( $model->$command() )?></td>
<?php
}
}
?>
</tr>
<?php
}
?>
</table>
Re: SHort tags
Posted: Sun Feb 15, 2009 5:33 pm
by Eran
By the way, on the topic of smarty:
http://nosmarty.net/
Re: SHort tags
Posted: Sun Feb 15, 2009 7:47 pm
by josh
How is it offtopic?
Re: SHort tags
Posted: Tue Feb 17, 2009 9:23 am
by panic!
Am I the only person who prefers the older curly brackets to the newer VB style if/endif syntax?