简体   繁体   中英

PHP.ini does not work

I opened the notepad, inserted 3 lines in it, saved it as php.ini, and uploaded it in public_html, but I am still getting an error that requires to first switch the magic quotes off. The syntax of the three lines is as following:

magic_quotes_gpc = 0 
magic_quotes_runtime = 0 
magic_quotes_sybase = 0 

What am I doing wrong?

use phpinfo() function to see what php.ini file you're actually using

You can probably alter these settings in a .htaccess configuration file as well:

php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag magic_quotes_sybase off

See PHP: How to change configuration settings .

Most hosting companies lets you define a local ini file. Check their support pages, and see where you should put your php.ini file for it to be read by the php engine. If they have an option for this, you don't have to worry about restarting the server.

If you can't find any info about it, create a page with the following code:

<?php phpinfo(); ?>

And look for the property named "Configuration File (php.ini) Path". This is where you should put the file.

It's not meant to be placed in the public_html folder... it should be in your PHP installation folder.

Php.ini is not usually located in public_html. If you can't access your real php.ini, try writing

php_flag magic_quotes_gpc off

in a .htaccess file (in public_html).

Most hosting companies won't let you play around with the php.ini unless you rent a dedicated server from them. On that, you could try on page php.ini settings like the following:

ini_set("magic_quotes_gpc", "0");
ini_set("magic_quotes_runtime", "0"); 
ini_set("magic_quotes_sybase", "0");

If that doesn't work, then you'll have to ask your hosting company about it.

On CentOS 8 run

service php-fpm restart

To read the edited php.ini file

Well, you have to change your main php.ini which I don't think is in public_html. Moreover, in order to see the changes you have to restart your php engine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM