Jump to content

Is this php?


Drummin

Recommended Posts

Yes, this is called the "short tags notation". It's basically the same as <?php ecvho $aset[siteDescription]; ?>, though I suspect that 'SiteDescription' shouldn't be a constant.

 

Anyway, the short tags have been deprecated for quite a while now, and the vast majority of web hosts have them turned off. So I recommend staying away from them, and just using the regular full tags instead.

Link to comment
Share on other sites

Never been real good with terminology but an unquoted name in brackets [name] would be a constant, right?  And I understand that the "name" in brackets should be quoted ['name'].  I do that all the time.  But what is that called?

 

Also can I get an answer if the code posted above is valid? 

Link to comment
Share on other sites

And I understand that the "name" in brackets should be quoted ['name'].  I do that all the time.  But what is that called?

 

It's a string.

 

Also can I get an answer if the post above is valid?

 

No, it's not valid. You know you can always try these simple script to see if they work?

Link to comment
Share on other sites

OK, so in other words, valid markup would be full echo then, correct?

<?php echo $aset['SiteDescription']; ?>

OR

<?php echo "{$aset['SiteDescription']}"; ?>

... and there no valid "notation" type formatting with the equal sign for this and all lines like this would need to be replaced, correct?

 

Note: it's not my site or code so testing isn't all that easy.  Just wanted to understand if there was in fact notation type scripting and if so, the correct way to write it.  Thanks for the feedback.

Link to comment
Share on other sites

Anyway, the short tags have been deprecated for quite a while now, and the vast majority of web hosts have them turned off. So I recommend staying away from them, and just using the regular full tags instead.

 

They are enabled by default in PHP 5.4+ I consider it good practice to use them in view/template files, bad in all other instances, makes it more readable.

 

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.

Link to comment
Share on other sites

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.