Skip to content

Strange (buggy?) side effect of PHP 8's new string/number comparison changes #8857

Closed
@kingIZZZY

Description

@kingIZZZY

Relevant

If the intent was to have "saner numeric strings" then mission failed successfully? (or maybe only in this weird obscure case)

Description

The following code:

<?php
echo phpversion(), PHP_EOL;
var_dump("10=" > 1);
var_dump("10=" > 2);
var_dump("10=" >= 10);

Resulted in this output:

7.4.0 thru 7.4.30
bool(true)
bool(true)
bool(true)

8.0.1 thru 8.1.7
bool(true)
bool(false)
bool(true)

But I expected this output instead:

bool(true)
bool(true)
bool(true)

PHP Version

8.0.1 - 8.1.7, 7.4.0 - 7.4.30

Operating System

Ubuntu 20.04.4

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