Bug #77286 [Com]: The array key like '123' Not a string?
| From: | xpigeon at 163 dot com | Date: | Wed, 12 Dec 2018 05:55:43 +0000 |
| Subject: | Bug #77286 [Com]: The array key like '123' Not a string? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218407@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77286&edit=1
ID: 77286
Comment by: xpigeon at 163 dot com
Reported by: xpigeon at 163 dot com
Summary: The array key like '123' Not a string?
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Windows 7
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
to: a at b dot c dot de
Yeah! I just want find this!
But indeed, I read this document,
But I was NOT read it carefully!
Previous Comments:
------------------------------------------------------------------------
[2018-12-12 05:41:10] a at b dot c dot de
It's not a bug if it's a deliberate and documented change.
http://www.php.net/manual/zh/migration73.deprecated.php#migration73.deprecated.core.string-search
------------------------------------------------------------------------
[2018-12-12 04:43:45] xpigeon at 163 dot com
Thanks!
I have this code in a project, it runs ok in php7.2;
But in php7.3, it show Notice Error, So I report is as a bug!
æ¨ä»æçé®ç®±å蹩èçè±æä¸çåºææ¯æ¥ä¸å½ï¼ï¼
忬¡æè°¢ï¼
------------------------------------------------------------------------
[2018-12-12 04:15:09] requinix@php.net
http://php.net/manual/zh/language.types.array.php
>
> å
嫿忳æ´åå¼çå符串ä¼è¢«è½¬æ¢ä¸ºæ´åãä¾å¦é®å
> "8" å®é
ä¼è¢«å¨å为 8ã使¯ "08"
> åä¸ä¼å¼ºå¶è½¬æ¢ï¼å 为å
¶ä¸æ¯ä¸ä¸ªåæ³çåè¿å¶æ°å¼ã
var_dump($key) -> int(123), int(456), int(789), string(3) "abc", string(3)
"xyz"
------------------------------------------------------------------------
[2018-12-12 04:10:17] xpigeon at 163 dot com
This line will Annotatedï¼
```
if(strstr($value,"$key")){ // is OK
```
-=> Edit as
```
//if(strstr($value,"$key")){ // is OK
```
------------------------------------------------------------------------
[2018-12-12 04:07:16] xpigeon at 163 dot com
Description:
------------
In the array like this:
```
'123'=>'abc'
```
The key like '123' Not as a string?
Test script:
---------------
<?php
$value = 'mystr-abcd-1234';
$keys = ['123'=>0, '456'=>0, '789'=>0, 'abc'=>0,
'xyz'=>0];
foreach($keys as $key=>$v){
if(strstr($value,"$key")){ // is OK
if(strstr($value,$key)){ // Notice Error
$keys[$key]=1;
}
}
var_dump($keys);
die();
/*
php7.3
strstr(): Non-string needles will be interpreted as strings in the future.
Use an explicit chr() call to preserve the current behavior
*/
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77286&edit=1