Skip to content

Change in variable assignment behavior as argument #22256

@devsseb

Description

@devsseb

Description

The following code:

<?php
$text = 'abc';
$offset = 0;
$char = substr($text, $offset, $offset = strpos($text, 'b', $offset));
var_dump($char);

Resulted in this output with PHP 8.2.31 :

string(1) "a" 

Resulted in this output with PHP 8.4.21 :

string(1) "b" 

PHP Version

PHP 8.2.31 (cli) (built: May  8 2026 07:20:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.31, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.31, Copyright (c), by Zend Technologies

PHP 8.4.21 (cli) (built: May  8 2026 05:56:48) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.21, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.21, Copyright (c), by Zend Technologies

Operating System

PHP 8.2.31 : Debian 12.14 - PHP 8.4.21 : Debian 13.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions