note 128276 added to function.explode
| From: | kontakt at mateusz-sikora dot net | Date: | Fri, 03 Mar 2023 09:56:00 +0000 |
| Subject: | note 128276 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220233@lists.php.net to get a copy of this message | ||
Official Description
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array
PHP 4.4.9 Description
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array|false
PHP 5.6.40, 7.4.30 Description
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array|null
PHP 8.0.0, 8.1.9 Description
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array
Code:
```
<?php
var_dump(explode('', new stdClass()));
```
Result for 4.4.9:
```
Notice: Object to string conversion in /home/user/scripts/code.php on line 3
Warning: explode(): Empty delimiter. in /home/user/scripts/code.php on line 3
bool(false)
```
Result for 5.6.40, 7.4.30:
```
Warning: explode() expects parameter 2 to be string, object given in /home/user/scripts/code.php on
line 3
NULL
```
Result for 8.1.9, 8.0.0:
```
Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, stdClass
given in /home/user/scripts/code.php:3
Stack trace:
#0 /home/user/scripts/code.php(3): explode('', Object(stdClass))
#1 {main}
thrown in /home/user/scripts/code.php on line 3
```
Code:
```
<?php
var_dump(explode(',', new stdClass()));
```
Result for 4.4.9:
```
Notice: Object to string conversion in /home/user/scripts/code.php on line 3
array(1) {
[0]=>
string(6) "Object"
}
```
Result for 5.6.40, 7.4.30:
```
Warning: explode() expects parameter 2 to be string, object given in /home/user/scripts/code.php on
line 3
NULL
```
Result for 8.1.9, 8.0.0:
```
Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, stdClass
given in /home/user/scripts/code.php:3
Stack trace:
#0 /home/user/scripts/code.php(3): explode(',', Object(stdClass))
#1 {main}
thrown in /home/user/scripts/code.php on line 3
```
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 5.226.70.162)
----
Manual Page -- https://php.net/manual/en/function.explode.php
Edit -- https://main.php.net/note/edit/128276
Del: integrated -- https://main.php.net/note/delete/128276/integrated
Del: useless -- https://main.php.net/note/delete/128276/useless
Del: bad code -- https://main.php.net/note/delete/128276/bad+code
Del: spam -- https://main.php.net/note/delete/128276/spam
Del: non-english -- https://main.php.net/note/delete/128276/non-english
Del: in docs -- https://main.php.net/note/delete/128276/in+docs
Del: other reasons-- https://main.php.net/note/delete/128276
Reject -- https://main.php.net/note/reject/128276
Search -- https://main.php.net/manage/user-notes.php