note 123430 added to language.types.array
| From: | webmaster+phpnet at sascha-ahlers dot de | Date: | Thu, 13 Dec 2018 12:32:06 +0000 |
| Subject: | note 123430 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209892@lists.php.net to get a copy of this message | ||
This weird error occurs in PHP 7.1.8:
Do anybody know why this happened? At the end, it is the same logical thing, just another writing
style.
<?php
/* this will return a illegal offset type: */
$_devices = array();
$i = 0;
foreach ( $devices as $device )
{
$this->_devices[$i] = [
['path'] => '',
['included_paths'] => array(),
['excluded_paths'] => array(),
['cbytes'] => 0,
['cfiles'] => 0,
['cfolders'] => 0
];
$i++;
}
?>
<?php
/* this is basically the same result but other writing style will pass without an error, but less
good readable */
$this->_devices = array();
$i = 0;
foreach ( $devices as $device )
{
$this->_devices[$i]['path'] = '';
$this->_devices[$i]['included_paths'] = array();
$this->_devices[$i]['excluded_paths'] = array();
$this->_devices[$i]['cbytes'] = 0;
$this->_devices[$i]['cfiles'] = 0;
$this->_devices[$i]['cfolders'] = 0;
$i++;
}
?>
----
Server IP: 92.48.119.85
Probable Submitter: 85.203.46.226
----
Manual Page -- http://php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/123430
Del: integrated -- https://master.php.net/note/delete/123430/integrated
Del: useless -- https://master.php.net/note/delete/123430/useless
Del: bad code -- https://master.php.net/note/delete/123430/bad+code
Del: spam -- https://master.php.net/note/delete/123430/spam
Del: non-english -- https://master.php.net/note/delete/123430/non-english
Del: in docs -- https://master.php.net/note/delete/123430/in+docs
Del: other reasons-- https://master.php.net/note/delete/123430
Reject -- https://master.php.net/note/reject/123430
Search -- https://master.php.net/manage/user-notes.php