Jump to content

Recommended Posts

I'm a big fan of these:

 

HTML (Inline PHP)

<p>I'm a normal text</p>
<p class="<?=($bold)?"bold":"italic"?>">I should be bold or italic based on a PHP Variable!!!</p>

Note: some server's don't have "<?=" enabled this is simply "<?php echo" so the long version would be:

<?php echo ($bold)?"bold":"italic"; ?>

Edited by DarkerAngel

"Short tags" are deprecated and shouldn't be used, they'll be out of the language entirely soon.

 

You may want to check your facts on that :)

 

http://www.php.net/manual/en/ini.core.php#ini.short-open-tag

 

This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available

 

What I think has been depreciated from the short tags, to my knowledge, is the opening <? which should be depreciated. I tend to use the <?= for .phtml type template files.

Edited by premiso

"Short tags" were marked for removal in PHP6, but that "official" decision is nowhere to be found in their changelogs.

 

Googling for it produces many articles like this one reporting on the short tag removal (which applied to both <? ?> and <?=$var?>).

 

As far as I can tell:

 

Short tags and short tag echoes were considered the same thing, and controlled by an ini setting.

 

They were deprecated briefly in the spring 2009.

 

That decision was reversed in the summer of 2009 (and I didn't notice).

 

PHP 5.4 split short tags and short echoes into two separate features, and turned short echoes on regardless of short tag settings.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.