& 什么是变量前面的符号表示什么意思?
我正在“剖析”PunBB,它的功能之一是检查 BBCode 标签的结构,并尽可能修复简单的错误:
function preparse_tags($text, &$errors, $is_signature = false)
$error
& 是什么意思? > 变量是什么意思?
I'm 'dissecting' PunBB, and one of its functions checks the structure of BBCode tags and fix simple mistakes where possible:
function preparse_tags($text, &$errors, $is_signature = false)
What does the &
in front of the $error
variable mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这意味着通过引用传递变量,而不是传递多变的。这意味着当程序流返回到调用代码时,对 preparse_tags 函数中该参数的任何更改都会保留。
输出:
It means pass the variable by reference, rather than passing the value of the variable. This means any changes to that parameter in the
preparse_tags
function remain when the program flow returns to the calling code.Output:
它确实通过引用传递而不是通过值传递。
这允许函数在调用函数的范围内更改其自身范围之外的变量。
例如:
在
preparse_tags
函数的情况下,它允许函数返回已解析的标签,但允许调用父级获得任何错误,而无需检查返回值的格式/类型。It does pass by reference rather than pass by value.
This allows for the function to change variables outside of its own scope, in the scope of the calling function.
For instance:
In the case of the
preparse_tags
function, it allows the function to return the parsed tags, but allow the calling parent to get any errors without having to check the format/type of the returned value.它接受对变量的引用作为参数。
这意味着函数对参数所做的任何更改(例如,
$errors = "Error!"
)都会影响调用函数传递的变量。It accepts a reference to a variable as the parameter.
This means that any changes that the function makes to the parameter (eg,
$errors = "Error!"
) will affect the variable passed by the calling function.这意味着在错误位置传递的变量将被被调用的函数修改。请参阅此了解详细信息。
It means that the variable passed in the errors position will be modified by the called function. See this for a detailed look.