<?php
//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:<br>';
var_dump($p);
echo 'leave function test.<br>';
} var_dump($a);
test($a);
var_dump($a);
echo '<hr>';
function test2()
{
global $a;
$len=count($a);
for($i=0;$i<$len;$i++)
{
$a[$i]='Ex~' . $a[$i];
}
echo 'in function test2:<br>';
var_dump($a);
echo 'leave function test2.<br>';
} 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 =>

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)

PassArrayByCopy_test.php的更多相关文章

随机推荐

  1. 命令行编译带外部包依赖的java源文件 [以JDBC MySQL8为例]

    环境: MySQL8 JDK11(SE) 首先下载MySQL8的JDBC驱动 https://dev.mysql.com/downloads/connector/j/选 PlatForm Indepe ...

  2. Windows开机自动登陆 开/关:登录需按Ctrl+Alt+del的功能

    Win10.Win7.WinXP开机自动登录: Win+R组合键打开“运行”,输入“netplwiz” 在弹出的“用户帐户”窗口中,把取消勾选“要使用本机,用户必须输入用户名和密码”,然后“应用”. ...

  3. LeetCode 1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix (最少翻转次数将二进制矩阵全部置为0)

    给一个矩阵mat,每个格子都是0或1,翻转一个格子会将该格子以及相邻的格子(有共同边)全部翻转(0变为1,1变为0) 求问最少需要翻转几次将所有格子全部置为0. 这题的重点是数据范围,比赛结束看了眼数 ...

  4. layer弹出框,zIndex不断增加的问题

    针对layer弹出框每次进行弹出操作时z-index不断加1的问题,手动设置过zIndex值不管用,每次关闭时清空layer对象也不管用. 解决办法: 修改layer.js,,将红框代码改为绿框代码, ...

  5. IScroll在某些win10版本下的奇怪问题

    客户的电脑环境: win10版本 企业微信: useragent mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml, like ...

  6. springboot: xercesImpl.jar和xml-apis.jar (系统找不到指定的文件)

    springboot内置的tomcat为8.5.23, tomcat在8.5.2 中 修改了加载jar的方式,8.5.2 版本会解析jar中MANIFEST.MF文件,当该文件包含class-path ...

  7. CMake的含义和用法解读

    什么是 CMake 你或许听过好几种 Make 工具,例如 GNU Make ,QT 的 qmake ,微软的 MS nmake,BSD Make(pmake),Makepp,等等.这些 Make 工 ...

  8. .net core 2.2部署到Windows Server 2012 R2 standard

    安装.net core 2.2 下载地址:https://dotnet.microsoft.com/download/dotnet-core/2.2 找到ASP.NET Core Runtime 2. ...

  9. Flutter实体与JSON解析的一种方法

    vs code作为编辑器 1. 首先,json对象与字符串的转换是使用json.encode和json.decode的,需要导入import 'dart:convert'; 这里主要的自然不是这个,而 ...

  10. Windows Server - 用tomcat部署finereport

    原博地址:https://blog.csdn.net/qq_39019865/article/details/80969728