V
V
Viktor Yanyshev2018-10-17 20:44:27
PHP
Viktor Yanyshev, 2018-10-17 20:44:27

Why is open_short_tag not working in Nginx?

Installed nginx, php5.6-fpm. Created a host config for nginx:

Host

server {
    listen 8080;

    server_name test.local;
    root /var/www/html/test;
    index index.php;

   access_log /logs/nginx/access.log;
   error_log /logs/nginx/error.log;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~* ^.+\.(js|css|ttf|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|tar|bz2|pdf|doc|docx|rtf|xls|ppt|mp3)$ {
        #access_log off;
        #log_not_found off;
        #expires 3d; # кеширование статики 3 дня
        try_files $uri =404;
    }

    location ~ ^/assets/.*\.php$ {
        deny all;
    }

    location ~ .*\.php$ {
        fastcgi_pass   127.0.0.1:9056;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~* /\. {
        deny all;
    }
}


Created index.php in /var/www/html/test directory :
<?= ini_get('short_open_tag'); ?>
<? echo 'Hello'; ?>

In php.ini set open_short_tag = On Restarted Nginx and php-fpm. I go test.local and gives the following result:
5bc77493a88c0566051380.png
If index.php contains <?php, then everything works.
Why is this and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-10-17
Alexsev @MaxGoody

ini_set('short_open_tag', true);
In general, using short tags is a bad practice.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question