Jump to content

PHP5: How to ignore "<?" errors (scripts without "<?php")


Recommended Posts

Hi.

 

Just installed PHP5 on my server, and found out that some of my PHP scripts start with "<?" instead of "<?php", so my application is showing the PHP code.

 

Is there any php.ini configuration to ignore this? I want to survive with this until I modify the code during this week.

 

Thank you very much,

-- Thomas

Link to comment
https://forums.phpfreaks.com/topic/97957-php5-how-to-ignore/
Share on other sites

The only current change in php6 concerning short tags is that the <% option has been eliminated and there is discussion about flagging inconstant code that mixes short <? and full <?php opening php tags.

 

[rant]

Sadly, <? is currently still part of php6 (I suspect that the person who thought two ways of doing the same thing, where one way won't always work and one will always work, is probably still on the php.ini development committee.)

[/rant]

Link to comment
https://forums.phpfreaks.com/topic/97957-php5-how-to-ignore/#findComment-501311
Share on other sites

So what, because some people use XML they remove it for everybody?

I have never used XML once because I never had to. All our applications are database driven. It would break pretty much all of our scripts if they removed it. (although not really hard to make a regular expression to replace all short tags with long tags)

 

 

I can see having the flag, which is fine, but if they remove it completely... I personally would think it is retarded.

 

Link to comment
https://forums.phpfreaks.com/topic/97957-php5-how-to-ignore/#findComment-501467
Share on other sites

If you go back and actually read what I wrote, carefully, you will discover that short open tags are currently part of php6.

 

If they would make the php parser a little smarter (I have seen a hack that does), it would be able to tell that <?xml is not a short tag followed by the letters xml.

 

But the truth remains, short open tags are a bad idea and result in code that is not portable between server configurations. Just look at how many posts there are on this forum - "I just changed servers and I am seeing my php code in my browser". The answer is always the same, write code that will always be parsed by using full <?php tags, because you won't necessarily be on a server where you can turn on short open tags.

 

Php.net itself recommends against using them -

 

; NOTE: Using short tags should be avoided when developing applications or

; libraries that are meant for redistribution, or deployment on PHP

; servers which are not under your control, because short tags may not

; be supported on the target server. For portable, redistributable code,

; be sure not to use short tags.

Link to comment
https://forums.phpfreaks.com/topic/97957-php5-how-to-ignore/#findComment-501781
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.