gpt4 book ai didi

PHP Bug 还是我对语言的误解?

转载 作者:可可西里 更新时间:2023-11-01 12:50:32 25 4
gpt4 key购买 nike

<分区>

这是我不理解的代码(作为输出)。

<?php
$x = ['test1', 'test2', 'test3', 'test4'];
echo "First FOREACH\n";
foreach ($x as &$y)
{
echo $y."\n";
}
echo "\n\nSecond FOREACH\n";
foreach ($x as $y)
{
echo $y."\n";
}

?>

输出:

First FOREACH
test1
test2
test3
test4

Second FOREACH
test1
test2
test3
test3

PS:我正在运行它:

php -v
PHP 5.6.11-1ubuntu3.1 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com