[php-src] Issue #22658: `ReflectionConstant::__toString()` with a string value with null bytes truncates output
| From: | DanielEScherzer | Date: | Thu, 09 Jul 2026 18:33:12 +0000 |
| Subject: | [php-src] Issue #22658: `ReflectionConstant::__toString()` with a string value with null bytes truncates output | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252383@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/22658
Author: DanielEScherzer
### Description
The following code:
```php
<?php
define('DEMO', "f\0oo");
$r = new ReflectionConstant('DEMO');
echo $r;
var_dump( $r->getValue() );
```
Resulted in this output:
```
Constant [ string DEMO ] { f }
string(4) "foo"
```
But I expected this output instead (with a null byte in the first "foo" the same way that
there is in the second)
```
Constant [ string DEMO ] { foo }
string(4) "foo"
```
https://3v4l.org/Au101#v
### PHP Version
```plain
8.4+
```
### Operating System
_No response_