Monday 24 April 2017

operands - PHP &$string - What does this mean?




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



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



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


Answer



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



Ref: http://www.php.net/manual/en/language.references.pass.php


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...