ArrayAccess::offsetSet
(PHP 5, PHP 7, PHP 8)
ArrayAccess::offsetSet — 设置一个偏移位置的值
参数
offset
-
待设置的偏移位置。
value
-
需要设置的值。
返回值
没有返回值。
注释
注意:
如果另一个值不可用,那么
offset
参数将被设置为null
,就像下面的示例。<?php
$arrayaccess[] = "first value";
$arrayaccess[] = "second value";
print_r($arrayaccess);
?>以上示例会输出:
Array ( [0] => first value [1] => second value )
注意:
This function is not called in assignments by reference and otherwise indirect changes to array dimensions overloaded with ArrayAccess (indirect in the sense they are made not by changing the dimension directly, but by changing a sub-dimension or sub-property or assigning the array dimension by reference to another variable). 而是调用 ArrayAccess::offsetGet()。 只有该方法通过引用返回,操作才会成功。
+添加备注
用户贡献的备注
此页面尚无用户贡献的备注。
备份地址:http://www.lvesu.com/blog/php/arrayaccess.offsetset.php