4

I can't change the php.ini for some reason,

how can I do it in code level?

2
  • If you have access to your php.ini, I would first try to find out why you can't change any values in there. Commented May 4, 2010 at 17:09
  • note that ini_set won't help with parse errors. .htaccess is another option where available Commented May 4, 2010 at 17:13

5 Answers 5

4

Try

  • ini_set — Sets the value of a configuration option

Example from Manual:

if (!ini_get('display_errors')) {
    ini_set('display_errors', 1);
}

but keep in mind your hosting service might have disabled programmatic setting of ini settings.


Also keep in mind that you have to have error_reporting enabled:

Example from Manual:

// Report all PHP errors
error_reporting(-1);
Sign up to request clarification or add additional context in comments.

2 Comments

Isn't error_reporting(-1); enough ? Do I also set display_errors to on?
@user198729 error_reporting just sets what is reported, not if it is displayed.
1

Use ini_set (https://www.php.net/manual/en/function.ini-set.php)

Specifically,

ini_set('display_errors', 'E_ALL');

should work

1 Comment

@Col. Shrapnel What's so ridiculous about it?
0

Runtime configuration of error reporting can be finetuned with a number of functions, listed here: http://www.php.net/manual/en/errorfunc.configuration.php

But most directly related to your question, use error_reporting(E_ALL), and display_errors(1)

Comments

0
error_reporting(-1); //Passing in the value -1 will show every possible error, even when new levels and constants are added in future PHP versions
ini_set('display_errors', 'On');

Doc available there:

Another way (if your server supports it) is with an .htaccess file:

php_flag display_errors on
php_value error_reporting -1

3 Comments

(tip) Passing in the value -1 will show every possible error, even when new levels and constants are added in future PHP versions.
I guess because it's bytewise and -1 equals to all flags raised?
because Rasmus said so twitter.com/rasmus/status/7448448829 ;) well, actually, it's also at the bottom of the manual page for error_reporting.
0

In PHP:

error_reporting(E_ALL | E_STRICT);

From an .htaccess file:

php_value error_reporting 6143 

6143 is the integer value of E_ALL, since apache won't understand "E_ALL"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.