<?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. Spring Cloud Gateway的全局异常处理

    Spring Cloud Gateway中的全局异常处理不能直接用@ControllerAdvice来处理,通过跟踪异常信息的抛出,找到对应的源码,自定义一些处理逻辑来符合业务的需求. 网关都是给接口 ...

  2. Elasticsearch由浅入深(九)搜索引擎:query DSL、filter与query、query搜索实战

    search api的基本语法 语法概要: GET /_search {} GET /index1,index2/type1,type2/_search {} GET /_search { , } h ...

  3. EPPlus.Core 处理 Excel 报错之天坑 WPS

    最近工作中常常有有数据处理的需求,一个Excel动不动就是上十万的数据量,在用 EPPlus.Core 导入数据入库的时候遇到了一个莫名其妙的问题 The given key 'rId2' was n ...

  4. LeetCode题库整理(自学整理)

    1. Two Sum 两数之和       来源:力扣(LeetCode) 题目:给定一个整数数组和一个目标值,找出数组中和为目标值的两个数.你可以假设每个输入只对应一种答案,且同样的元素不能被重复利 ...

  5. C#编写了一个基于Lucene.Net的搜索引擎查询通用工具类:SearchEngineUtil

    最近由于工作原因,一直忙于公司的各种项目(大部份都是基于spring cloud的微服务项目),故有一段时间没有与大家分享总结最近的技术研究成果的,其实最近我一直在不断的深入研究学习Spring.Sp ...

  6. gitlab 账号

    gitlab 账号 国外版-比较慢 https://gitlab.com/hgnulb 国内版-比较快 https://git.lug.ustc.edu.cn/hglibin github账号 htt ...

  7. [转帖]PostgreSQL的时间/日期函数使用

    PostgreSQL的时间/日期函数使用 https://www.cnblogs.com/mchina/archive/2013/04/15/3010418.html 这个博客的 文章目录比上一个好十 ...

  8. 常见的Redis面试"刁难"问题,值得一读

    Redis有哪些数据结构? 字符串String.字典Hash.列表List.集合Set.有序集合SortedSet. 如果你是Redis中高级用户,还需要加上下面几种数据结构HyperLogLog.G ...

  9. scrapy 使用

    启动方式: 写一个启动文件,与配置文件同级   from scrapy.cmdline import execute import sys,os sys.path.append(os.path.dir ...

  10. SpringApplication到底run了什么(下)

    在上篇文章中SpringApplication到底run了什么(上)中,我们分析了下面这个run方法的前半部分,本篇文章继续开工 public ConfigurableApplicationConte ...