开发者

how to avoid writing <?php in php file

i have one old website where my php tag start from

 <?

now i want to run on new server wi开发者_运维技巧th php 5.x.x its not working

its working on

  <?php 

can i avoid this...

Thanks


You will have to enable shorts tags:

short_open_tag = On

from php.ini

Note:

That would work if:

PHP_INI_ALL in PHP 4.0.0. PHP_INI_PERDIR in PHP < 5.3.0

Suggestion:

You should make it a habit of yours to always write full php tags <?php...?> because short tags have shown security concerns and won't be supported in the future versions.


The correct way would be to change it to <?php, however, if you change short_open_tag in php.ini to 1 or true and reload server, it will work as well.

short_open_tag = 1

Again, it would be wiser to change all <? occurrences to <?php.


You can configure PHP to enable short open tags:

short_open_tags = 1

See the ini file configuration docs.


It is a configuration setting of your PHP-Installation.

short_open_tag


Use Dreamweaver to Replace All instances of <? to <?php or change like the other answerers said.


To avoid editing a centralized php.ini file and affecting all sites using the php.ini, if you're able to edit .htaccess files or apache virtualhost configs, you can add a line to the .htaccess file or virtualhost config file for a cleaner effect:

php_value short_open_tag "1"

Or, the more complete version for a .htaccess file:

<FilesMatch "\.(php)$">
    php_value short_open_tag "1"
</FilesMatch>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜