Skip to content

error_reporting() Sometimes Sets Bizarre Values #18867

Closed as not planned
Closed as not planned
@miqrogroove

Description

@miqrogroove

Description

I'm having a strange problem with PHP 8.2.26 and 8.4.2 on a DreamHost server. I have a test case that gives a totally different result when I run it on the PHP sandbox at onlinephp.io, so I don't understand why this works in some environments but not others.

When setting the error reporting level to -1 the server is interpreting that as a large negative integer.

<?php
error_log('The default error reporting level is ' . error_reporting());
error_reporting(-1); // Report all errors
error_log('Top of file error reporting level is ' . error_reporting());
error_log('The correct level would be ' . E_ALL);

Output:

The default error reporting level is 22517
Top of file error reporting level is -10251
The correct level would be 32767

The reporting level is being set to -10251 which is not correct, and I'm not getting any error reports.

When I attempted to resolve this by switching to E_ALL, then I got this equally problematic situation:

error_reporting(E_ALL); // Report all errors.
error_log('Top of file error reporting level is ' . error_reporting());
error_log('The correct level would be ' . E_ALL);

Output:

Top of file error reporting level is 22517
The correct level would be 30719

Is there a bug here, or is this somehow specific to the server I'm using?

PHP Version

PHP 8.2.26 (cli) (built: Nov 21 2024 20:16:53) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions