• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Turn off PHP warnings from Command Line?

Paul Larson

Basic Pleskian
Server operating system version
CentOS Linux release 7.9.2009
Plesk version and microupdate number
Obsidian 18.0.46
This is probably a Centos Question, but I've noticed more verbose warning output since upgrading a site to PHP 8.1, e.g.

Code:
-bash-4.2$ php myscript.php
The following error occurred:
E_DEPRECATED: explode(): Passing null to parameter #2 ($string) of type string is deprecated

Centos Version:

Code:
-bash-4.2$ cat /etc/*rel*
CentOS Linux release 7.9.2009 (Core)
Derived from Red Hat Enterprise Linux 7.9 (Source)

Code:
-bash-4.2$ php -v
PHP 8.1.14 (cli) (built: Jan  9 2023 10:16:54) (NTS)

I get the same output when I use an absolute path:

Code:
-bash-4.2$ /opt/plesk/php/8.1/bin/php myscript.php
The following error occurred:
E_DEPRECATED: explode(): Passing null to parameter #2 ($string) of type string is deprecated
 
It's not a OS related issue, nor is it an Plesk related issue. It is merely a PHP issue.

It also the correct behavior for PHP 8.1 as passing null to non-nullable parameters of built-in functions will result in a deprecation notice. Even tough it is just a notification and not an actual error, the obvious solution would be to fix the issue in your code. Making it future proof for PHP version where passing null to non-nullable parameters are actually deprecated and will cause an error.

If that's not what your after then you can suppress deprecation notices by removing E_DEPRECATED from the error_reporting value on the PHP settings page of your domain in Plesk (or in the PHP settings tab of your service plan if want to get rid of the deprecation notices for all of your domains). Or instead add the error_reporting() function to your script.

There is no way to only suppress the deprecation notices on command line only. It's all or nothing.
 
Last edited:
Back
Top