Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_array function with empty array #15971

Closed
qlixes opened this issue Sep 21, 2024 · 2 comments
Closed

in_array function with empty array #15971

qlixes opened this issue Sep 21, 2024 · 2 comments

Comments

@qlixes
Copy link

qlixes commented Sep 21, 2024

Description

The following code:

<?php
print_r(in_array('127.0.0.1', []);

Resulted in this output:

empty blank page

But I expected this output instead:

it shoud show boolean type

PHP Version

PHP 8.3

Operating System

OSX Ventura

@DanielEScherzer
Copy link
Contributor

This is unrelated to in_array, which returns false fine. What you are seeing is that print_r for false doesn't show anything

php-src/Zend/zend_operators.c

Lines 1016 to 1017 in 64d959e

case IS_FALSE:
return ZSTR_EMPTY_ALLOC();

@damianwadley
Copy link
Member

Meanwhile var_dump doesn't have that... "quirk" of behavior.

@damianwadley damianwadley closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants