Ubuntu php ini short open tag

[ Solved -10 Answers] PHP How to enable PHP short tags

[pastacode lang=”php” manual=”Configuration%20File%20(php.ini)%20Path%3A%20%2Fetc%0ALoaded%20Configuration%20File%3A%20%20%20%20%20%20%20%20%20%2Fetc%2Fphp.ini%0AScan%20for%20additional%20.ini%20files%20in%3A%20%2Fetc%2Fphp.d%0AAdditional%20.ini%20files%20parsed%3A%20%20%20%20%20%20%2Fetc%2Fphp.d%2Fcurl.ini%2C%0A%2Fetc%2Fphp.d%2Ffileinfo.ini%2C%0A%2Fetc%2Fphp.d%2Fgd.ini%2C%0A%2Fetc%2Fphp.d%2Fjson.ini%2C%0A%2Fetc%2Fphp.d%2Fmcrypt.ini%2C%0A%2Fetc%2Fphp.d%2Fmysql.ini%2C%0A%2Fetc%2Fphp.d%2Fmysqli.ini%2C%0A%2Fetc%2Fphp.d%2Fpdo.ini%2C%0A%2Fetc%2Fphp.d%2Fpdo_mysql.ini%2C%0A%2Fetc%2Fphp.d%2Fpdo_sqlite.ini%2C%0A%2Fetc%2Fphp.d%2Fphar.ini%2C%0A%2Fetc%2Fphp.d%2Fsqlite3.ini%2C%0A%2Fetc%2Fphp.d%2Fzip.ini%0A” message=”php code” highlight=”” provider=”manual”/]

See 2nd line from the comment output.The file will be in the mentioned path.

  • Open php.ini file and find short_open_tag. By default it is in off change it to on.
  • Restart the server,execute this comment
  • In reality all 21st Century PHP apps will have FastCGI Process Manager(php-fpm) so once you have added php-info() into your test.php script and checked the correct path for php.ini
  • IMPORTANT: then you must restart your php-fpm process so this can work!

and then finally restart your nginx/http server

[pastacode lang=”php” manual=”%20%20sudo%20service%20nginx%20restart%0A” message=”php code” highlight=”” provider=”manual”/]

As simple, as that, follow the following steps:

In CentOS 6(tested on Centos 7 too) you can’t set short_open_tag in /etc/php.ini for php-fpm. You will have error:

[pastacode lang=”php” manual=”ERROR%3A%20%5B%2Fetc%2Fphp.ini%3A159%5D%20unknown%20entry%20’short_open_tag’%0AERROR%3A%20Unable%20to%20include%20%2Fetc%2Fphp.ini%20from%20%2Fetc%2Fphp-fpm.conf%20at%20line%20159%0AERROR%3A%20failed%20to%20load%20configuration%20file%20’%2Fetc%2Fphp-fpm.conf’%0AERROR%3A%20FPM%20initialization%20failed%0A” message=”php code” highlight=”” provider=”manual”/]

You must edit config for your site, which can found in /etc/php-fpm.d/www.conf And write at end of file:

[pastacode lang=”php” manual=”php_value%5Bshort_open_tag%5D%20%3D%20%20On%0A” message=”php code” highlight=”” provider=”manual”/]

If you are using Ubuntu with Apache+php5, then on current versions there are 2 places where you need to change to short_open_tag = On

  1. /etc/php5/apache2/php.ini – this is for the pages loaded through your web server (Apache)
  2. /etc/php5/cli/php.ini – this configuration is used when you launch your php files from command line, like: php yourscript.php – that goes for manually or cronjob executed php files directly on the server.

If you are using xampp in windows then please do following

1.Open XAMPP control panel.

You will found ; short_open_tag

and keep it as short_open_tag = on

Finally, restart your Apache server

[pastacode lang=”php” manual=”%3B%20Default%20Value%3A%20On%0A%3B%20Development%20Value%3A%20Off%0A%3B%20Production%20Value%3A%20Off%0A%3B%20http%3A%2F%2Fphp.net%2Fshort-open-tag%0A%3Bshort_open_tag%3DOff%20%20%20%3C–Comment%20this%20out%0A%3B%20XAMPP%20for%20Linux%20is%20currently%20old%20fashioned%0Ashort_open_tag%20%3D%20On%20%20%20%3C–Uncomment%20this%0Ashareimprove%20this%20answer%0Aanswered%20Jan%209%20’14%20at%2011%3A38%0A” message=”php code” highlight=”” provider=”manual”/]

Источник

Включить/Выключить short_open_tag в PHP

Опция «short_open_tag» определяет, будет ли обрабатываться PHP код, написанный между тегами . Вообще, пользователи используют данные теги чтобы писать PHP-код. В этой статье «Включить/Выключить short_open_tag в PHP» я расскажу как можно включить или выключить параметр «short_open_tag» в PHP.

Включить параметр short_open_tag в PHP

Чтобы включить short_open_tag, необходимо отредактировать файла конфигурации PHP «php.ini» и установите следующий параметр:

Читайте также:  Java util optional example

Выключить параметр short_open_tag в PHP

Чтобы выключить данную опцию, используйте:

После чего, нужно перезапустить веб-сервер.

Тестирования short_open_tag в PHP

Чтобы проверить включен или выключен параметр, создайте php файл и вставьте:

Если при открытии браузера ( по данному файлу) вы увидите:

The short_open_tag is ON/OFF

То это говорит что данный параметр включен и работает, иначе, вы увидите следующий php код:

Что говорит что данный параметр выключен и не используется. На этом все, моя тема «Включить/Выключить short_open_tag в PHP» завершена.

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Рубрики

  • Arch Linux (167)
  • Commands (36)
  • Debian’s (635)
    • Administration tools Ubuntu (37)
    • Backups Debian’s (7)
    • Database в Ubuntu (58)
    • Games (игры) (1)
    • Monitoring в Debian и Ubuntu (49)
    • Virtualization в Ubuntu / Debian/ Linux Mint (41)
      • Docker (22)
      • Kubernetes (6)
      • KVM (4)
      • OpenVZ (3)
      • Vagrant (5)
      • VirtualBox (6)
      • ArgoCD (1)
      • Concourse (1)
      • Gitlab (1)
      • Jenkinks (4)
      • Spinnaker (1)
      • Apache (32)
      • Cherokee (1)
      • FTP-services (5)
      • Lighttpd (1)
      • Nginx (26)
      • PHP (27)
      • Proxy для Debian’s (2)
      • Tomcat (4)
      • Панели управления в Ubuntu/Debian/Mint (24)
      • Установка и настройка почты на Ubuntu/Debian (12)
      • Хранилища (clouds) (2)
      • Administration tools freeBSD (19)
      • Database во FreeBSD (52)
      • Monitoring во freeBSD (37)
      • Virtualization во FreeBSD (22)
      • VoIP (1)
      • Установка Web сервисов (91)
      • Установка и настройка почты (6)
      • Установка из ports (пакетов) (19)
      • Установка из sorce code (исходников) (23)
      • Непрерывная интеграция (CI) (27)
      • Database в MacOS (36)
      • Monitoring в Mac OS (31)
      • Security (безопасность) (12)
      • Virtualization в Mac OS (30)
        • Docker (19)
        • Kubernetes (6)
        • Vagrant (5)
        • VirtualBox (5)
        • ArgoCD (1)
        • CircleCI (1)
        • Concourse (1)
        • Gitlab (1)
        • Jenkinks (4)
        • Spinnaker (1)
        • Administration tools CentOS (49)
        • Backups RPM’s (4)
        • Database в CentOS (68)
        • Monitoring в CentOS (67)
        • Virtualization в CentOS/ Red Hat/ Fedora (42)
          • Docker (23)
          • Kubernetes (6)
          • KVM (5)
          • OpenVZ (2)
          • Vagrant (5)
          • VirtualBox (6)
          • VMWare (3)
          • ArgoCD (1)
          • Concourse (1)
          • Gitlab (1)
          • Jenkinks (4)
          • Spinnaker (1)
          • Apache (35)
          • Cherokee (1)
          • DNS (3)
          • FTP (10)
          • Nginx (33)
          • PHP (34)
          • Proxy для RedHat’s (2)
          • Tomcat (2)
          • Voice (2)
          • Панели управления в CentOS/Red Hat/Fedora (27)
          • Прокси сервер на CentOS/RHEL/Fedora (4)
          • Установка и настройка почты на CentOS/RHEL/Fedora (14)
          • Хранилища (clouds) (1)

          соц сети

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Архив новостей

          Свежие записи

          Свежие комментарии

          • Глеб к записи Установка Adobe Flash Player в Debian/Ubuntu/Mint
          • Максим к записи Заблокировать User Agents используя Nginx
          • Денис к записи Как включить EPEL репозиторий на CentOS
          • Гость к записи Закомментировать/Раскомментировать строки vi/vim в Unix/Linux
          • Sergey к записи Установка и настройка OpenVPN сервера на Debian/Ubuntu/Linux Mint

          Источник

          How to Enable PHP Short Open Tag (short_open_tag)?

          Enable PHP short open tags in PHP.ini

          In this article we will enable the short_open_tag option in the PHP configuration to allow us to use the short tag

          Introduction

          PHP short open tags is a deprecated feature of PHP and it’s been recommended for several years that you not use the short tag “short cut” and instead to use the full tag combination. But because this short cut has been a feature for such a long time, it’s currently still supported for backwards compatibility.

          You may have upgraded PHP recently or moved your web app to a different server and been hit with a PHP fatal error similar to below:

          PHP message: PHP Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)

          1. Locate php.ini

          Firstly, you need to locate your php.ini file. In this example, our php.ini is located in /etc/php/7.4/apache2/php.ini , however, this may be different for you depending on your PHP version. If you are unsure, please read:

          2. Apache

          Edit the PHP config. Replace php7.4 with your own version, e.g, php5.6 , php7.1 , etc. (Use ls /etc/php/ if you are not sure which version is installed.)

          Not there? If you are using PHP FPM, php.ini might be in /etc/php/7.4/fpm/php.ini –

          Search for short_open_tag = (Press CTRL + W to search in nano)

           Save changes and close nano (Press CTRL + X and then press y and ENTER )

          If you are using PHP-FPM, you must restart that service. Replace php7.4 with your own version, e.g, php5.6 , php7.1 , etc.

          3. Nginx or Apache with PHP-FPM

          Edit the PHP config. Replace php7.4 with your own version, e.g, php5.6 , php7.4 , etc.

          Search for short_open_tag = (Press CTRL + W to search in nano)

          Save changes and close nano (Press CTRL + X and then press y and ENTER )

          Restart PHP-FPM. Replace php7.4 with your own version, e.g, php5.6 , php7.4 , etc.

          short_open_tag

          With the wide spread use of XML and use of these tags by other languages, the server can become easily confused and end up parsing the wrong code in the wrong context. The short_open_tag setting tells PHP whether the short form ( ) of PHP’s open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use inline. Otherwise, you can print it with PHP, for example: ‘; ?> . Also, if disabled, you must use the long form of the PHP open tag ( ).

          Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

          p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

          5 replies

          Leave a reply Cancel reply

          As short tags can be disabled it is recommended to only use the normal tags ( and ) to maximise compatibility.

          This means that the setup is not disabled by setting short_open_tag to Off.

          In other words, only the form is disabled, not the form.

          Thanks it really helped me

          Источник

          Enable PHP short tags on nginx and apache

          However if you need it turned on for sure, then continue with the tutorial. This will turn on the short tags for all types of short codes related to php including the too.

          How to enable PHP short tags on apache and nginx server

          To turn on the php short tags on apache server (on any distribution – linux, windows or mac os x) (or on any setup like lamp, xampp or mamp, etc) simply locate your php.ini file (find the one that’s practical on your server environment, os and distro etc) and uncomment or add (uncommenting means removing this sign before the line: ‘;’

          If it has the value arealy make sure it says “on” and not “off”.

          Another way, if php is running as apache module, specially when you don’t have access to php.ini file, you can do it via .htaccess using:

          php_flag short_open_tag on
          php_value short_open_tag 1

          The method works on IIS too.

          Note: most probably location for your php.ini is: /etc/php5/apache2/php.ini (however confirm the one specific to yours)

          You can use php –ini (on command line) to locate the loaded configuration file too.

          Tip: On WAMP server you can trn it on by right clicking the icon> PHP> PHP settings > short open tag and voila!

          Tip: On XAMPP server goto xampp control panel > config button > PHP (pnp.ini) option

          Restart your server / service after php.ini update

          Don’t forget to restart your nginx or apache server after making these changes. If you know how to restart the service thats perfect too!

          You can restart the php-fpm service on nginx by:

          sudo service php-fpm restart

          You need to include the version of php you’re using in some cases if the command php-fpm doesn’t identify your running php service. It should look something like this:

          sudo service php5-fpm restart
          sudo service php7.0-fpm restart

          You can restart nginx from command line via:

          sudo service nginx restart

          (doing both above steps might be required on nginx server, let me know your feedback!)

          This might help you turn on the short tags for your php code files!

          You might also like

          Источник

Оцените статью