Skip to content

Empty("0") #25336

Closed
Closed

Description

@KarelWintersky

Description

Is it reasonable to hope that the illogical behavior of the empty() will one day be corrected?

var_dump(empty(null));      // bool(true)
var_dump(empty(''));        // bool(true)
var_dump(empty('0'));       // bool(true)   <--- THIS
var_dump(empty('0.0'));     // bool(false)
var_dump(empty(' '));       // bool(false)
var_dump(empty('false'));   // bool(false)
var_dump(empty([]));        // bool(true)
var_dump(empty(0));         // bool(true)
var_dump(empty(0.0));       // bool(true)
var_dump(empty(false));     // bool(true)

String '0' is not empty really, but the language construct empty considers this to be otherwise.

Perhaps one day it will become a function?

Activity

  1. kallesommernielsen commented on Nov 9, 2026

    @kallesommernielsen
    Member

    No, it is not realistic because of the impressive BC break that comes along with it, if you disagree with this then you can make an RFC and try to make your case on the internals mailing list but beyond that it is not a realistic consideration as of current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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