auto_prepend_file not working in php.ini - php

I can't get the auto_prepend_file setting in php.ini to work. I tested the path directly in the project folder I'm working on and it works seamlessly. Based off everything below, does anyone have some ideas as to what to try next? Any help would be greatly appreciated!
// This did nothing
ini_set("auto_prepend_file","/Applications/MAMP/bin/php/php5.5.10/prepend.php");
// This allowed it to work by including it in the index.php but it's not using the auto_append_file setting
require_once '/Applications/MAMP/bin/php/php5.5.10/conf/prepend.php';
Bash Commands Used:
# When I did this, it gave me the correct path
$ cat /Applications/MAMP/conf/php5.5.10/php.ini | grep auto_prepend_file
auto_prepend_file ="/Applications/MAMP/bin/php/php5.5.10/conf/prepend.php"
# But when I ran this command, it shows that there are no values (just like it does when running phpinfo() )
$ php -i | grep auto_prepend_file
auto_prepend_file => no value => no value
# Nothing is output when I run this command
$ php -r "echo ini_get('auto_prepend_file');"
The php.ini paths from phpinfo()
Configuration File (php.ini) Path /Applications/MAMP/bin/php/php5.5.10/conf
Loaded Configuration File /Library/Application Support/appsolute/MAMP PRO/conf/php.ini
I found a ton of php.ini files on my system
/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
/Applications/MAMP/conf/php5.5.10/php.ini
/Users/alexcory/jarvis/tmp/backup/php.ini~
// Not sure if these have any effect
/private/etc/php-fpm.conf.default
/private/etc/php.ini.default
Contents of prepend.php
<?php
die('Hello World'); // Haven't been able to get "Hello World" to show
require_once dirname( _file_ ) . '/kint/Kint.class.php';
StackOverflow questions referenced.
auto_prepend_file is not working in cli mode
Why would auto_prepend_file works in .htaccess but not in php.ini?
php version issue in auto_prepend_file

MAMP allows you to open the php.ini file from within the application by going to File ▶ Edit Template ▶PHP ▶ php {version} php.ini.
That should open the php.ini in an editor such as a TextEdit. I hope that helps!

Related

Running PHP short tag on localhost Bitnami Wordpress [duplicate]

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.

Can't use echo function in PHP on Ubuntu [duplicate]

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.

OSX Sierra - how to increase PHP memory limit correctly?

I need to increase the memory limit for PHP on the command line so I can use Composer.
Output of php -i | grep memory_limit
memory_limit => 256M => 256M
Output of php --ini
Configuration File (php.ini) Path: /usr/local/php5/lib
Loaded Configuration File: /usr/local/php5/lib/php.ini
Scan for additional .ini files in: /usr/local/php5/php.d
Additional .ini files parsed: /usr/local/php5/php.d/10-extension_dir.ini,
/usr/local/php5/php.d/20-extension-opcache.ini,
/usr/local/php5/php.d/40-openssl.ini,
/usr/local/php5/php.d/50-extension-apcu.ini,
/usr/local/php5/php.d/50-extension-curl.ini,
/usr/local/php5/php.d/50-extension-gmp.ini,
/usr/local/php5/php.d/50-extension-igbinary.ini,
/usr/local/php5/php.d/50-extension-imap.ini,
/usr/local/php5/php.d/50-extension-intl.ini,
/usr/local/php5/php.d/50-extension-mcrypt.ini,
/usr/local/php5/php.d/50-extension-memcache.ini,
/usr/local/php5/php.d/50-extension-memcached.ini,
/usr/local/php5/php.d/50-extension-mongo.ini,
/usr/local/php5/php.d/50-extension-mssql.ini,
/usr/local/php5/php.d/50-extension-oauth.ini,
/usr/local/php5/php.d/50-extension-pdo_dblib.ini,
/usr/local/php5/php.d/50-extension-pdo_pgsql.ini,
/usr/local/php5/php.d/50-extension-pgsql.ini,
/usr/local/php5/php.d/50-extension-propro.ini,
/usr/local/php5/php.d/50-extension-raphf.ini,
/usr/local/php5/php.d/50-extension-readline.ini,
/usr/local/php5/php.d/50-extension-redis.ini,
/usr/local/php5/php.d/50-extension-solr.ini,
/usr/local/php5/php.d/50-extension-ssh2.ini,
/usr/local/php5/php.d/50-extension-twig.ini,
/usr/local/php5/php.d/50-extension-uploadprogress.ini,
/usr/local/php5/php.d/50-extension-xdebug.ini,
/usr/local/php5/php.d/50-extension-xhprof.ini,
/usr/local/php5/php.d/50-extension-xsl.ini,
/usr/local/php5/php.d/60-extension-pecl_http.ini,
/usr/local/php5/php.d/99-liip-developer.ini
So I edit /usr/local/php5/lib/php.ini but it's always 256MB...
Restarted Apache, but it's cli, but still no success.
One of the other included files has a memory_limit directive. Use this command to find which one:
grep memory_limit /usr/local/php5/php.d/*
The "Additional .ini files parsed" are parsed later, and will override settings in the main php.ini.
Maybe you should find out where php.ini is
sometimes this won't do:
php -i | grep php.ini # turns out I just can't edit /etc/php.ini even when I'm root
then you can try this:
locate php.ini # turns out it's here: /private/etc/php.ini
finally, edit /private/etc/php.ini with sudo
sudo vim /private/etc/php.ini
save the file with
:wq!
job done.
I found out that you need to change the memory limit in this file :
/usr/local/etc/php/*your php version*/conf.d/php-memory-limits.ini
Worked like a charm after modifying this file.

php if statement in html is matching all conditions [duplicate]

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.

Mac OS X Homestead - edit php.ini

I have Homestead installed on my Mac (El Capitan 10.11.6). I need to enable short tags via my php.ini file. All the posts I've read say to go to a path like /etc/php/7.0/... but I don't have that php folder in etc/ . I can see the files /etc/php.ini.default and /etc/php.ini.default-5.2-previous. In the /etc/php.ini.default the short tag config looks like this:
short_open_tag = Off
I can edit (via sudo) to read like this
short_open_tag = On
But not sure if that did the job, as I don't know if I need to (or how to) restart php or nginx...?
if you are using php-fpm, you need to restart that !
I dont know your stack, so have no practical advice to offer. However, to make certain you are editing the right .ini, however, on the box running php, issue the following :
php -r "echo phpinfo();" | grep "\.ini"
which will list the ini files loaded, and their location(s). That is the one you need to edit. The output looks like this on my box :
Configuration File (php.ini) Path => /usr/local/etc/php/5.5
Loaded Configuration File => /usr/local/etc/php/5.5/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed => /usr/local/etc/php/5.5/conf.d/ext-igbinary.ini,
/usr/local/etc/php/5.5/conf.d/ext-intl.ini,
/usr/local/etc/php/5.5/conf.d/ext-libevent.ini,
/usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini,
/usr/local/etc/php/5.5/conf.d/ext-memcached.ini,
/usr/local/etc/php/5.5/conf.d/ext-opcache.ini,
/usr/local/etc/php/5.5/conf.d/ext-propro.ini,
/usr/local/etc/php/5.5/conf.d/ext-raphf.ini,
/usr/local/etc/php/5.5/conf.d/ext-xdebug.ini,
/usr/local/etc/php/5.5/conf.d/zzz_ext-http.ini
user_ini.filename => .user.ini => .user.ini

Categories