PassArrayByCopy_test.php
2021-07-14 02:08
标签:blog space text func string class count cti let string string string in function test: string string string leave function test. string string string in function test2: string string string leave function test2. string string string PassArrayByCopy_test.php 标签:blog space text func string class count cti let 原文地址:http://www.cnblogs.com/sky20080101/p/7076818.htmlphp
//PassArrayByCopy_test.php
$a=array("a","b","c");
function test(array $p)
{
$len=count($p);
for($i=0;$i$len;$i++)
{
$p[$i]=‘Ex~‘ . $p[$i];
}
echo ‘in function test:
‘;
var_dump($p);
echo ‘leave function test.
‘;
}
var_dump($a);
test($a);
var_dump($a);
echo ‘
‘;
function test2()
{
global $a;
$len=count($a);
for($i=0;$i$len;$i++)
{
$a[$i]=‘Ex~‘ . $a[$i];
}
echo ‘in function test2:
‘;
var_dump($a);
echo ‘leave function test2.
‘;
}
test2();
var_dump($a);
?>array (size=3)
0 => string ‘a‘ (length=1)
1 => string ‘b‘ (length=1)
2 => string ‘c‘ (length=1)
in function test:
array (size=3)
0 => string ‘Ex~a‘ (length=4)
1 => string ‘Ex~b‘ (length=4)
2 => string ‘Ex~c‘ (length=4)
leave function test.
array (size=3)
0 => string ‘a‘ (length=1)
1 => string ‘b‘ (length=1)
2 => string ‘c‘ (length=1)
in function test2:
array (size=3)
0 => string ‘Ex~a‘ (length=4)
1 => string ‘Ex~b‘ (length=4)
2 => string ‘Ex~c‘ (length=4)
leave function test2.
array (size=3)
0 => string ‘Ex~a‘ (length=4)
1 => string ‘Ex~b‘ (length=4)
2 => string ‘Ex~c‘ (length=4)
array (size=3)
0 =>
‘a‘ (length=1)
1 =>
‘b‘ (length=1)
2 =>
‘c‘ (length=1)
array (size=3)
0 =>
‘Ex~a‘ (length=4)
1 =>
‘Ex~b‘ (length=4)
2 =>
‘Ex~c‘ (length=4)
array (size=3)
0 =>
‘a‘ (length=1)
1 =>
‘b‘ (length=1)
2 =>
‘c‘ (length=1)
array (size=3)
0 =>
‘Ex~a‘ (length=4)
1 =>
‘Ex~b‘ (length=4)
2 =>
‘Ex~c‘ (length=4)
array (size=3)
0 =>
‘Ex~a‘ (length=4)
1 =>
‘Ex~b‘ (length=4)
2 =>
‘Ex~c‘ (length=4)
上一篇:CSS z-index 属性
下一篇:js初级入门