Jump to content

Writing Code without the 'php' at the start


sofcare1

Recommended Posts

Hi,

I work from two separate servers/pcs.  On one, I have to start my code with '<?php', while on the other I can start with just '<?'.  Why is that and how can I adjust the other server so that I don't have to write 'php' after the question mark?  Thanks.

Chris

Link to comment
Share on other sites

It should be noted that <? is discouraged.

By whom?  The only issue with them at this point is portability.  If you are writing code to be run on your server, in your company etc.  Then the control is there.  Zend as well as many other frameworks/templating schemes use short tags in MVC view code.  As of 5.4 they will always be available so once that is the commonly installed version it won't be an issue.  That being said, I only use them in one line PHP statements in view templates.

Edited by AbraCadaver
Link to comment
Share on other sites

I think you mean <?= which like you say will be always available since 5.4 and are used in Zend views. <? on the other hand won't and may even disappear in the future.

 

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.

http://www.php.net/manual/en/ini.core.php#ini.short-open-tag Edited by ignace
Link to comment
Share on other sites

Portability IS the key problem, AbraCadaver, mainly because systems that do not support shortcut tags meaning any code within such tags is directly sent to the client without any previous formating or parsing which is critical.

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.