SHort tags
Moderator: General Moderators
Re: SHort tags
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.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: SHort tags
Why does alternative syntax hurt your head?
In HTML templates it's way better than standard PHP, no?
In HTML templates it's way better than standard PHP, no?
Re: SHort tags
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.
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.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: SHort tags
While that is usually the case, they are slightly more aesthetically appealing:he first thing I think when I see a codebase with short tags is that the programmer was a newbie and inexperienced.
<?= $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
How, because it reminds you of the 60s?PCSpectra wrote:In HTML templates it's way better than standard PHP, no?
Re: SHort tags
I agree too, alt syntax reminds me of VB and is ambiguous with the existing syntax tho
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: SHort tags
Considering I wasn't born until 1979...no...not really.How, because it reminds you of the 60s?
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>Code: Select all
<div>
<?php if($a == $b): ?>
<strong><?php echo $title; ?></strong>
<?php endif; ?>
</div>
Re: SHort tags
Code: Select all
<?php if($a == $b): ?>
<strong><?php echo $title; ?></strong>
<?php endif; ?>-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: SHort tags
I realize that, re-read the discussion and you'll see I said:
EDIT | The point was given the examples I gave above:
Isn't as nice to lok at as:
TO which josh replied:Short tags are nice in alternative syntax templates though...
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?alternative syntax hurts my head.
EDIT | The point was given the examples I gave above:
Code: Select all
<?php echo $title; ?>Code: Select all
<?= $title; ?>Re: SHort tags
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
Neither.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:
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
How is it offtopic?
Re: SHort tags
Am I the only person who prefers the older curly brackets to the newer VB style if/endif syntax?