InsaneCoder
InsaneCoder

Reputation: 8268

Override few php.ini settings on hosting server without changing rest of the settings

I have just hosted my first website on hosting server, but I do not have access to the php.ini file of the server (as expected). So to change some settings like

display_errors = off
log_errors = on
file_upload = off

I created a php.ini file in the root directory with these only these 3 lines added, but it seems that this new php.ini files completely replaces the default php.ini file and I start getting errors like class PDO not found etc.

I just want to tweak few settings through this new php.ini files, leaving other settings intact. How can I do that? I don't want to do it throughini_set as it might require changes to many php files, I guess.

Upvotes: 2

Views: 772

Answers (2)

n-dru
n-dru

Reputation: 9420

You can use ini_set in separate file and auto prepend it in .htaccess:

php_value auto_prepend_file "prepend.php"

and in prepend.php:

ini_set('display_errors',0);//etc, you can place here other configurations as well

Upvotes: 0

fijas
fijas

Reputation: 1274

You should use an .htaccess file instead of directly modifying the php.ini file. Your requirement translates to .htaccess like this:

php_flag log_errors on
php_flag display_errors on
php_flag file_upload off

Upvotes: 3

Related Questions