Jump to content

<?= or <?php echo


UnknownPlayer

Recommended Posts

  Quote

I saw that <?=$var?> instead of <?php echo $var; ?> can be used for echo, does it work on every server?

the best practice is to always use full php tags in your code.

Some, or maybe most servers do not have this setting enabled. what if you were to migrate your code to a server that had short tags disabled and access to the php.ini was prohibited?

Link to comment
https://forums.phpfreaks.com/topic/254101--/#findComment-1302715
Share on other sites

  Quote

No it does not work on every server. You can configure it to be enabled or disabled, excepting php5.4 where it is now enabled by default and unable to be disabled.

 

Anecdote:

We had a candidate for a job interview and as part of the reviewing process we had him write some PHP code. This guy had 10+ years of prof. experience with PHP but always started his code with <?.

 

As he tried to run his code he noticed nothing appeared... Compelely baffled, he calls the interviewer and tells him the server is broken since he can see his PHP code when he opens the browser's view source window...

 

 

We didn't hire him but I'm pretty sure that guy will start all his files now with <?php

Link to comment
https://forums.phpfreaks.com/topic/254101--/#findComment-1302798
Share on other sites

  Quote

  Quote

No it does not work on every server. You can configure it to be enabled or disabled, excepting php5.4 where it is now enabled by default and unable to be disabled.

 

Anecdote:

We had a candidate for a job interview and as part of the reviewing process we had him write some PHP code. This guy had 10+ years of prof. experience with PHP but always started his code with <?.

 

As he tried to run his code he noticed nothing appeared... Compelely baffled, he calls the interviewer and tells him the server is broken since he can see his PHP code when he opens the browser's view source window...

 

 

We didn't hire him but I'm pretty sure that guy will start all his files now with <?php

Heh, smarts

Link to comment
https://forums.phpfreaks.com/topic/254101--/#findComment-1302832
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.