PHP 8.5.0 Alpha 4 available for testing

Voting

: min(nine, seven)?
(Example: nine)

The Note You're Voting On

info at comfortnet dot de
1 month ago
You should be careful when using pointers. The following example shows how an array is unintentionally distorted if the pointer variable is not treated with unset

<?php

echo '<pre>';

$arr = array ( 'a' => 'a' , 'b' => 'b' ) ;

var_dump ($arr) ;

foreach (
$arr as $index => &$data ) {}

var_dump ($arr) ;

// unset($data);

foreach ( $arr as $index => $data ) {}

var_dump ($arr) ;

?>

Output:

array(2) {
["a"]=>
string(1) "a"
["b"]=>
string(1) "b"
}
array(2) {
["a"]=>
string(1) "a"
["b"]=>
&string(1) "b"
}
array(2) {
["a"]=>
string(1) "a"
["b"]=>
&string(1) "a"
}

<< Back to user notes page

To Top