Change in variable assignment behavior as argument
Open
Nobody has claimed this yet.
Bug
Category: Engine
Status: Verified
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example on PHP 8.2.31 and 8.4.21, then trace how argument evaluation and the assignment to $offset differ between versions. Determine which result matches PHP's intended semantics and identify the relevant interpreter behavior before adding regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100