Skip to content

Confusing error message #21507

@exakat

Description

@exakat

Description

The following code:

<?php

class X {
  const A = '1';
}
$c = 'b'; 
isset(X::{$c}); 

Resulted in this (valid) output:

atal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead)

but I cannot use null !== X::{$c}, which also yields a Fatal Error.

With a constant, this message should recommend using 'defined()' instead, or on top of the current recommendation.

PHP Version

Tested on PHP 8.5, but any version since 8.3

Operating System

Not applicable.

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