PHP& $ string-这是什么意思? [英] PHP &$string - What does this mean?

查看:152
本文介绍了PHP& $ string-这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索,但找不到任何东西.

I've been googling but I can't find anything.

$x->func(&$string, $str1=false, $str2=false);

$string &$string之前的&有什么作用?

what does that & before $string &$string do?

推荐答案

您正在通过引用分配该数组值.

You are assigning that array value by reference.

通过引用(& $)传递参数,并通过$传递参数是,当您通过引用传递参数时,您将在原始变量上工作,这意味着如果您在函数内部对其进行更改,则也将在其外部进行更改.将参数作为副本传递,函数将创建此变量的副本实例,然后对该副本进行处理,因此,如果在函数中对其进行更改,则不会在其外部进行更改

passing argument through reference (&$) and by $ is that when you pass argument through reference you work on original variable, means if you change it inside your function it's going to be changed outside of it as well, if you pass argument as a copy, function creates copy instance of this variable, and work on this copy, so if you change it in the function it won't be changed outside of it

参考: http://www.php.net/manual/zh/language.references .pass.php

这篇关于PHP& $ string-这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆