Skip to content

ReflectionConstant::__toString() with a string value with null bytes truncates output #22658

Description

@DanielEScherzer

Description

The following code:

<?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

8.4+

Operating System

No response

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions