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 fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php
I know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.
Thanks
Set
short_open_tag=On
in php.ini
And restart your Apache server.
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
This can be done by enabling short_open_tag in php.ini:
1.To locate php.ini file,on comment line execute
php --ini
you will get some thing like this,
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/zip.ini
See 2nd line from the comment output.The file will be in the mentioned path.
2.Open php.ini file and find short_open_tag. By default it is in off change it to on.
3.Restart the server,execute this comment
service httpd restart
Thanks
To set short tags to open from a Vagrant install script on Ubuntu:
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php5/apache2/php.ini
I can see all answers above are partially correct only.
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
Go to php.ini and set short_open_tag = On
IMPORTANT: then you must restart your php-fpm process so this can work!
sudo service php-fpm restart
and then finally restart your nginx/http server
sudo service nginx restart
you need to turn on short_open_tags.
short_open_tag = On
As simple, as that, follow the following steps:
Go to php.ini file
Find short_open_tag and set it to on
short_open_tag = On
Restart the server
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:
ERROR: [/etc/php.ini:159] unknown entry 'short_open_tag'
ERROR: Unable to include /etc/php.ini from /etc/php-fpm.conf at line 159
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed
You must edit config for your site, which can found in /etc/php-fpm.d/www.conf
And write at end of file:
php_value[short_open_tag] = On
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
/etc/php5/apache2/php.ini - this is for the pages loaded through your web server (Apache)
/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 edit your php.ini file, remember to restart your service (apache2, etc) for the edits to php.ini to take effect
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
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
;short_open_tag=Off <--Comment this out
; XAMPP for Linux is currently old fashioned
short_open_tag = On <--Uncomment this
You can follow the following steps:
1-> Go to php.ini file inside /etc/php/7.3/apache2 or inside your PHP version and
2-> Find short_open_tag and set it to On and removing ; from starting.
short_open_tag = On
3-> Restart the server
sudo service apache2 restart
if using xampp, you will notice the php.ini file has twice mentioned short_open_tag . Enable the second one to short_open_tag = On . The first one is commented out and you might be tempted to uncomment and edit it but it is over-ridden by a second short_open_tag
If you are using xampp in windows then please do following
Open XAMPP control panel.
Click on CONFIG button.
Go to PHP (php.ini) option.
Find short_open_tag using ctrl+f utility
You will found ;short_open_tag
kindly remove the semicolon (;) from line.
and keep it as short_open_tag = on
Finally, restart your Apache server
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php/7.2/apache2/php.ini
That works on php7.2 on ubuntu 16, same answer as above by Bradley Flood, although the directory in which the config file is stored has changed.
Also you can change the version in the php string to match your currently installed version.
For docker add this step to Dockerfile
ARG phpIniPath=/path/to/your/php.ini
RUN sed -i -e 's/^short_open_tag\s*=.*/short_open_tag = On/' $phpIniPath
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
short_open_tag = On
in php.ini
And restart your Apache Server.
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
Set the asp_tags = On and short_open_tag = On in both the files \apache\Apache2.2.21\bin\php.ini and \bin\php\php5.3.8\php.ini and then restart the apache server.
Related
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 fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php
I know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.
Thanks
Set
short_open_tag=On
in php.ini
And restart your Apache server.
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
This can be done by enabling short_open_tag in php.ini:
1.To locate php.ini file,on comment line execute
php --ini
you will get some thing like this,
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/zip.ini
See 2nd line from the comment output.The file will be in the mentioned path.
2.Open php.ini file and find short_open_tag. By default it is in off change it to on.
3.Restart the server,execute this comment
service httpd restart
Thanks
To set short tags to open from a Vagrant install script on Ubuntu:
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php5/apache2/php.ini
I can see all answers above are partially correct only.
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
Go to php.ini and set short_open_tag = On
IMPORTANT: then you must restart your php-fpm process so this can work!
sudo service php-fpm restart
and then finally restart your nginx/http server
sudo service nginx restart
you need to turn on short_open_tags.
short_open_tag = On
As simple, as that, follow the following steps:
Go to php.ini file
Find short_open_tag and set it to on
short_open_tag = On
Restart the server
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:
ERROR: [/etc/php.ini:159] unknown entry 'short_open_tag'
ERROR: Unable to include /etc/php.ini from /etc/php-fpm.conf at line 159
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed
You must edit config for your site, which can found in /etc/php-fpm.d/www.conf
And write at end of file:
php_value[short_open_tag] = On
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
/etc/php5/apache2/php.ini - this is for the pages loaded through your web server (Apache)
/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 edit your php.ini file, remember to restart your service (apache2, etc) for the edits to php.ini to take effect
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
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
;short_open_tag=Off <--Comment this out
; XAMPP for Linux is currently old fashioned
short_open_tag = On <--Uncomment this
You can follow the following steps:
1-> Go to php.ini file inside /etc/php/7.3/apache2 or inside your PHP version and
2-> Find short_open_tag and set it to On and removing ; from starting.
short_open_tag = On
3-> Restart the server
sudo service apache2 restart
if using xampp, you will notice the php.ini file has twice mentioned short_open_tag . Enable the second one to short_open_tag = On . The first one is commented out and you might be tempted to uncomment and edit it but it is over-ridden by a second short_open_tag
If you are using xampp in windows then please do following
Open XAMPP control panel.
Click on CONFIG button.
Go to PHP (php.ini) option.
Find short_open_tag using ctrl+f utility
You will found ;short_open_tag
kindly remove the semicolon (;) from line.
and keep it as short_open_tag = on
Finally, restart your Apache server
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php/7.2/apache2/php.ini
That works on php7.2 on ubuntu 16, same answer as above by Bradley Flood, although the directory in which the config file is stored has changed.
Also you can change the version in the php string to match your currently installed version.
For docker add this step to Dockerfile
ARG phpIniPath=/path/to/your/php.ini
RUN sed -i -e 's/^short_open_tag\s*=.*/short_open_tag = On/' $phpIniPath
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
short_open_tag = On
in php.ini
And restart your Apache Server.
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
Set the asp_tags = On and short_open_tag = On in both the files \apache\Apache2.2.21\bin\php.ini and \bin\php\php5.3.8\php.ini and then restart the apache server.
I have got this error PHP Fatal error: Directive 'safe_mode' is no longer available in PHP in Unknown on line 0 when I have updated my hosting PHP version from 5.6 to 7.2
how can I solve this problem or I must contact my hosting provider ?!
here is my php.ini setting file found in my mean path
; cPanel-generated PHP ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
magic_quotes_gpc = Off;
register_globals = Off;
default_charset = UTF-8;
memory_limit = 64M
max_execution_time = 36000
upload_max_filesize = 999M
safe_mode = On;
mysql.connect_timeout = 20;
session.auto_start = Off;
session.use_only_cookies = On;
session.use_cookies = On;
session.use_trans_sid = Off;
session.cookie_httponly = On;
session.gc_maxlifetime = 3600
allow_url_fopen = On
display_errors = On
;error_reporting = E_ALL;
allow_url_include = On
enable_dl = On
file_uploads = On
max_input_time = 60
max_input_vars = 1000
post_max_size = 8M
session.save_path = "/var/cpanel/php/sessions/ea3"
zlib.output_compression = Off
First, you should read up on safe_mode. In the docs, will see that:
Warning: This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
Second, you can get the error to go away by removing this line:
safe_mode = On;
NOTE: You must be certain to find the correct INI file. Some operating systems or methods of installing PHP will have a separate php.ini file for the web server and Command Line Interface (CLI). For example, on my ubuntu workstation, I have one for apache and one for CLI:
/etc/php5/cli/php.ini
/etc/php5/apache2/php.ini
To find out what INI file you should edit, I suggest looking at the output of phpinfo() and looking at the value for Loaded Configuration File. To do that on a web server, use this file:
<?php
phpinfo();
If you want to find out where the php.ini file is for CLI scripts, you can use this command:
php -i | grep "Loaded Configuration File"
If you are make changes to the ini file for your web server, you'll need to restart the web server for this change to take effect. On Ubuntu or other debian-based distros, you might do that with a command like so:
sudo service apache2 restart
You may need to tweak that command, depending on distro, distro version, apache version, etc. I believe that for CentOS or Red Hat-based distros, one of these should work:
sudo service httpd restart
sudo apachectl restart
NOTE: If your machine is configured to use php-fpm for handling PHP requests, then things work differently for your web server. Your system will maintain a process pool of PHP processes entirely separate from your web server. You will need to restart the PHP process pool. The command to accomplish that varies widely depending on the distro and your version of PHP. Check this page for your distro and see if you can find one that works.
For CLI invocations of PHP, the changes should take effect each time you run a new php script. You shouldn't have to restart anything for new commands to see the changes you made. If you have some long-running PHP script for some reason (very unusual) then you'd need to halt that process and re-invoke it after making your INI changes.
EDIT: I'd also point out that your INI file very clearly states you might get weird behavior on your CPANEL system. Make sure you follow its instructions:
; cPanel-generated PHP ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
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 fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php
I know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.
Thanks
Set
short_open_tag=On
in php.ini
And restart your Apache server.
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
This can be done by enabling short_open_tag in php.ini:
1.To locate php.ini file,on comment line execute
php --ini
you will get some thing like this,
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/zip.ini
See 2nd line from the comment output.The file will be in the mentioned path.
2.Open php.ini file and find short_open_tag. By default it is in off change it to on.
3.Restart the server,execute this comment
service httpd restart
Thanks
To set short tags to open from a Vagrant install script on Ubuntu:
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php5/apache2/php.ini
I can see all answers above are partially correct only.
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
Go to php.ini and set short_open_tag = On
IMPORTANT: then you must restart your php-fpm process so this can work!
sudo service php-fpm restart
and then finally restart your nginx/http server
sudo service nginx restart
you need to turn on short_open_tags.
short_open_tag = On
As simple, as that, follow the following steps:
Go to php.ini file
Find short_open_tag and set it to on
short_open_tag = On
Restart the server
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:
ERROR: [/etc/php.ini:159] unknown entry 'short_open_tag'
ERROR: Unable to include /etc/php.ini from /etc/php-fpm.conf at line 159
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed
You must edit config for your site, which can found in /etc/php-fpm.d/www.conf
And write at end of file:
php_value[short_open_tag] = On
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
/etc/php5/apache2/php.ini - this is for the pages loaded through your web server (Apache)
/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 edit your php.ini file, remember to restart your service (apache2, etc) for the edits to php.ini to take effect
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
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
;short_open_tag=Off <--Comment this out
; XAMPP for Linux is currently old fashioned
short_open_tag = On <--Uncomment this
You can follow the following steps:
1-> Go to php.ini file inside /etc/php/7.3/apache2 or inside your PHP version and
2-> Find short_open_tag and set it to On and removing ; from starting.
short_open_tag = On
3-> Restart the server
sudo service apache2 restart
if using xampp, you will notice the php.ini file has twice mentioned short_open_tag . Enable the second one to short_open_tag = On . The first one is commented out and you might be tempted to uncomment and edit it but it is over-ridden by a second short_open_tag
If you are using xampp in windows then please do following
Open XAMPP control panel.
Click on CONFIG button.
Go to PHP (php.ini) option.
Find short_open_tag using ctrl+f utility
You will found ;short_open_tag
kindly remove the semicolon (;) from line.
and keep it as short_open_tag = on
Finally, restart your Apache server
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php/7.2/apache2/php.ini
That works on php7.2 on ubuntu 16, same answer as above by Bradley Flood, although the directory in which the config file is stored has changed.
Also you can change the version in the php string to match your currently installed version.
For docker add this step to Dockerfile
ARG phpIniPath=/path/to/your/php.ini
RUN sed -i -e 's/^short_open_tag\s*=.*/short_open_tag = On/' $phpIniPath
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
short_open_tag = On
in php.ini
And restart your Apache Server.
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
Set the asp_tags = On and short_open_tag = On in both the files \apache\Apache2.2.21\bin\php.ini and \bin\php\php5.3.8\php.ini and then restart the apache server.
I'm using php5.5 and getting this error whenever I used the date function in PHP:
Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/info.php on line 1
the loaded configuration file is here:
/etc/php5/apache2/php.ini
so I changed the date.timezone setting into this:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Jakarta
; http://php.net/date.default-latitude
;date.default_latitude = 31.7667
; http://php.net/date.default-longitude
;date.default_longitude = 35.2333
; http://php.net/date.sunrise-zenith
;date.sunrise_zenith = 90.583333
; http://php.net/date.sunset-zenith
;date.sunset_zenith = 90.583333
Then I restart the server:
sudo /etc/init.d/apache2 restart
but still getting this error, I tried to check the .ini file in the Additional ini file location but none of it is overriding the date.timezone setting
I've checked the php.ini file permission, but still not working
please guide me to solve this problem, thanks..
Try this:
date.timezone = "Asia/Jakarta"
Edit:
Let's locate the correct php.ini. Fire this within apache / nginx / whatever web server deamon your using (because the command line version may be different by the one used by it).
<?php
phpinfo();
?>
What's the .ini in the output? Still the same?
Edit2:
After the php.ini edit, just restart the webserver (apache or nginx) ...
finally solved my problem,
this is my Loaded Configuration File:
/etc/php5/apache2/php.ini
modified the date.timezone here but it's not working.
So, I check the "Scan this dir for additional .ini files " values in phpinfo() which point to:
/etc/php5/apache2/conf.d
then I search date.timezone from all files in that folder but found none.
this is my Additional .ini file parsed value in phpinfo():
/etc/php5/apache2/conf.d/05-opcache.ini, /etc/php5/apache2/conf.d/10-pdo.ini, /etc/php5/apache2/conf.d/20-json.ini, /etc/php5/apache2/conf.d/20-mysql.ini, /etc/php5/apache2/conf.d/20-mysqli.ini, /etc/php5/apache2/conf.d/20-pdo_mysql.ini, /etc/php5/apache2/conf.d/20-xdebug.ini, /etc/php5/apache2/conf.d/30-mcrypt.ini
I modified /etc/php5/apache2/conf.d/20-xdebug.ini, and appended this line:
date.timezone = Asia/Jakarta
very weird but this solved my problem !!!
You should check out by locate php.in, if there somewhere has another one.
for me. there should have CLI for command line interface:
/etc/php5/cli/php.ini
/etc/php5/fpm/php.ini
change the /etc/php5/cli/php.ini
It works for me now.
Another solution for me after compiling PHP from source was to check php.ini was actually loading a config file. From command line
php --ini
returns
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Find it.
find -name "php.ini" #it was in /usr/local/php/php.ini
cp /usr/local/php/php.ini /usr/local/lib/php.ini
Restart php (in my case, /etc/init.d/php-fpm stop, /etc/init.d/php-fpm start) and it works fine. For some reason it got copied wrong.
Distro: Centos 7
Web Server: Nginx
Type: EC2 Instance
I've faced the same issue recently with PHP 5.6.4.
PHP 5.6.4 behaves strange
PHP 5.6.11 behaves normally as expected
When I put the date.timezone configuration option under [PHP] section in the configuration file it works fine for PHP 5.6.4. For example I've added the option at the very beginning of the php.ini file
[PHP]
date.timezone = "Europe/Stockholm"
But when I put the configuration option how this is shown in the example under [Date] section it does not work as expected, it looks like the option is ignored
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
; this does not work for me for PHP 5.6.4 but works fine for PHP 5.6.11
date.timezone = "Europe/Stockholm"
When I add option to the 20-xdebug.ini like it is suggestion in the accepted answer https://stackoverflow.com/a/20731466/2111430 the option is accepted because this file has only [PHP] section. Out of curiosity I tried other included ini files and it looks like I can use any one.
One more time, the issue happened for me only with PHP 5.6.4. When I changed the option on the server with PHP 5.6.11 it behaved exactly like I expected.
In my case I had 2 date.timezone= records in the php.ini file and the last one was overriding the first one. removing one of them solved my problem.
Also don't forget you need to restart the web server process.
It worked for me when I noticed that the date.timezone entry in php.ini was commented out. After removing the semicolon the timezone was set correctly.
If you set the date.timezone value in php.ini but it does not work (ie. local value and master value are different) then you might need to update something like this in your apache configuration file:
<IfModule mod_php5.c>
php_value date.timezone "Europe/Paris"
</IfModule>
Check for the conflicting settings in you php.ini, I had same issue and in my case xdebug settings defined before date.timezone causing this thing: For more detail refer: PHP Xdebug issue - date.timezone & session.save_path undefined
some command line php application installer (like the symfony installer, or even when php scripts are run from cli), use the ini file inside the php-cli directory
/etc/php5/cli/php.ini
this solved my similar issue in dependency checking process while installing Symfony.
I fixed this in Mac OSX El Captain creating a folder structure: /Library/Server/Web/Config/php and then creating a php.ini inside this new php folder just with the date.timezone directive.
Iam using PHP 7.3.6.
open xampp/php/php.ini
go to line 1967
set line date.timezone=Asia/Jakarta
Restart Apache
Hope answer your question
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 fine except that an SQL statement is being rendered differently. I don't know if this has to do with the script beginning with <?php instead of <? because I don't know from where to enable the <? from the PHP.ini so I changed it to <?php
I know that these 2 statements are supposed to mean the same but I need to test it with <? in order to ensure that the application is exactly the same. This way I can eliminate another possibility.
Thanks
Set
short_open_tag=On
in php.ini
And restart your Apache server.
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
This can be done by enabling short_open_tag in php.ini:
1.To locate php.ini file,on comment line execute
php --ini
you will get some thing like this,
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/zip.ini
See 2nd line from the comment output.The file will be in the mentioned path.
2.Open php.ini file and find short_open_tag. By default it is in off change it to on.
3.Restart the server,execute this comment
service httpd restart
Thanks
To set short tags to open from a Vagrant install script on Ubuntu:
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php5/apache2/php.ini
I can see all answers above are partially correct only.
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
Go to php.ini and set short_open_tag = On
IMPORTANT: then you must restart your php-fpm process so this can work!
sudo service php-fpm restart
and then finally restart your nginx/http server
sudo service nginx restart
you need to turn on short_open_tags.
short_open_tag = On
As simple, as that, follow the following steps:
Go to php.ini file
Find short_open_tag and set it to on
short_open_tag = On
Restart the server
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:
ERROR: [/etc/php.ini:159] unknown entry 'short_open_tag'
ERROR: Unable to include /etc/php.ini from /etc/php-fpm.conf at line 159
ERROR: failed to load configuration file '/etc/php-fpm.conf'
ERROR: FPM initialization failed
You must edit config for your site, which can found in /etc/php-fpm.d/www.conf
And write at end of file:
php_value[short_open_tag] = On
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
/etc/php5/apache2/php.ini - this is for the pages loaded through your web server (Apache)
/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 edit your php.ini file, remember to restart your service (apache2, etc) for the edits to php.ini to take effect
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
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
;short_open_tag=Off <--Comment this out
; XAMPP for Linux is currently old fashioned
short_open_tag = On <--Uncomment this
You can follow the following steps:
1-> Go to php.ini file inside /etc/php/7.3/apache2 or inside your PHP version and
2-> Find short_open_tag and set it to On and removing ; from starting.
short_open_tag = On
3-> Restart the server
sudo service apache2 restart
if using xampp, you will notice the php.ini file has twice mentioned short_open_tag . Enable the second one to short_open_tag = On . The first one is commented out and you might be tempted to uncomment and edit it but it is over-ridden by a second short_open_tag
If you are using xampp in windows then please do following
Open XAMPP control panel.
Click on CONFIG button.
Go to PHP (php.ini) option.
Find short_open_tag using ctrl+f utility
You will found ;short_open_tag
kindly remove the semicolon (;) from line.
and keep it as short_open_tag = on
Finally, restart your Apache server
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php/7.2/apache2/php.ini
That works on php7.2 on ubuntu 16, same answer as above by Bradley Flood, although the directory in which the config file is stored has changed.
Also you can change the version in the php string to match your currently installed version.
For docker add this step to Dockerfile
ARG phpIniPath=/path/to/your/php.ini
RUN sed -i -e 's/^short_open_tag\s*=.*/short_open_tag = On/' $phpIniPath
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
short_open_tag = On
in php.ini
And restart your Apache Server.
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
Set the asp_tags = On and short_open_tag = On in both the files \apache\Apache2.2.21\bin\php.ini and \bin\php\php5.3.8\php.ini and then restart the apache server.