Home  >  Article  >  php教程  >  PHP中数组,字符串和对象的在方法中的引用方式

PHP中数组,字符串和对象的在方法中的引用方式

WBOY
WBOYOriginal
2016-06-06 19:44:371155browse

读了几篇关于PHP方法调用参数,是传还是传引用的文章: http://blog.51yip.com/php/878.html http://www.cnblogs.com/zcy_soft/archive/2011/12/10/2283570.html 非常有趣的是,当方法调用的是对象是,传入的是引用。 而与Java不同的是,数组默认是传递,如

读了几篇关于PHP方法调用参数,是传值还是传引用的文章:


http://blog.51yip.com/php/878.html

http://www.cnblogs.com/zcy_soft/archive/2011/12/10/2283570.html


非常有趣的是,当方法调用的是对象是,传入的是引用。

而与Java不同的是,数组默认是值传递,如果加了”&“符号,那么就变成了引用传递。

顺便测试了字符串,结果与数组相同。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn