How to enable PHP short tags?

后端 未结 19 2418
清酒与你
清酒与你 2020-11-21 05:29

I have a web application on a Linux server which starts with

I needed to copy this application to a windows environment and everything is working

相关标签:
19条回答
  • 2020-11-21 05:38

    To enable short_open_tag for a particular domain with php-fpm, you must edit :

    /etc/php5/fpm/pool.d/xxxxxxxxxx.conf

    Where xxxxx is the socket number of the domain.

    And add : php_value[short_open_tag] = On

    0 讨论(0)
  • 2020-11-21 05:39

    I'v Changed the short_open_tag Off to On on my aws centos 7 instance and php7(PHP 7.0.33 (cli) (built: Dec 6 2018 22:30:44) ( NTS )), but its not reflecting the php info page and the code. So I refer may docs and find a solution on my case. Add an extra line after the short_open_tag as asp_tags = On after that restart Apache It works on the code and I go the output correctly

    php.ini file

    engine = On
    
    ; This directive determines whether or not PHP will recognize code between
    ; <? and ?> tags as PHP source which should be processed as such. It is
    ; generally recommended that <?php and ?> should be used and that this feature
    ; should be disabled, as enabling it may result in issues when generating XML
    ; documents, however this remains supported for backward compatibility reasons.
    ; Note that this directive does not control the <?= shorthand tag, which can be
    ; used regardless of this directive. 
    ; Default Value: On   
    ; Development Value: Off     
    ; Production Value: Off  
    ; http://php.net/short-open-tag
    
    short_open_tag = On
    
    ; Allow ASP-style <% %> tags   
    ; http://php.net/asp-tags
    asp_tags = On
    
    0 讨论(0)
  • 2020-11-21 05:40

    For Wamp Server users there is easier way: You may enable that setting simply (left) click once on the WampServer icon, choose PHP -> PHP settings -> short open tag. Wait for a second, then WampServer will automatically restart your PHP and also its web service.

    originally from: http://osticket.com/forums/showthread.php?t=3149

    0 讨论(0)
  • 2020-11-21 05:41

    you need to turn on short_open_tags.

    short_open_tag = On
    
    0 讨论(0)
  • 2020-11-21 05:45

    Set

    short_open_tag=On
    

    in php.ini

    And restart your Apache server.

    0 讨论(0)
  • 2020-11-21 05:45

    This can be done by enabling short_open_tag in php.ini:

    short_open_tag = on
    

    If you don't have access to the php.ini you can try to enable them trough the .htaccess file but it's possible the hosting company disabled this if you are on shared hosting:

    php_value short_open_tag 1
    

    For the people thinking that short_open_tags are bad practice as of php 5.4 the <?= ... ?> shorttag will supported everywhere, regardless of the settings so there is no reason not to use them if you can control the settings on the server. Also said in this link: short_open_tag

    0 讨论(0)
提交回复
热议问题