Jump to content

"<?php" required?


Recommended Posts

I just installed php on my server and I could get the test.php page to work(yippey!) but the rest of my scripts would fail.

 

I could not figure it out until I noticed the only difference between the test.php and the rest was the start of the php script. The non working scripts would start with "<?" and the test.php(working) uses "<?php". So, I added the "php" to the scripts and they worked!

 

Is this normal?

 

Most of my downloaded scripts use "<?" so obviously, it's not a problem for most people.

 

If this is not normal, how could I fix it to accept the standard "<?"

 

specs: Apache/1.3.33 (Darwin) PHP/5.2.4

Link to comment
Share on other sites

<? is not standard. It is a lazy way short cut that results in non-portable code. php.net recommends that any code that is to be distributed does not use short open tags -

 

; 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.

 

All the other php configuration settings are detectable by code at runtime and can be dealt with if your code relies on them, but if your code uses short open tags <?, your code won't run and a lot of people either cannot or won't have the ability to turn short open tags on.

Link to comment
Share on other sites

<? is not standard. It is a lazy way short cut that results in non-portable code. php.net recommends that any code that is to be distributed does not use short open tags -

 

; 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.

 

All the other php configuration settings are detectable by code at runtime and can be dealt with if your code relies on them, but if your code uses short open tags <?, your code won't run and a lot of people either cannot or won't have the ability to turn short open tags on.

 

I am not a php programmer so I simply assumed it was standard since 99.9% of my "php resource" scripts start with "<?" including some I paid for. I am now in the process of fixing every tag.

 

Thanks guys for helping me with this problem.

Link to comment
Share on other sites

Hi,

If you want quickly convert your short tage <? to <?php then go for for php tools.

Php software, quickly optimize your code and easily fix your problems.

 

Its also saves your lots of time.

short php tags are not accpeted by some web hosts, so make sure.

 

Thanks,

Vishal

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.