Page 1 of 1
Search String
Posted: Thu Oct 01, 2009 1:25 pm
by Wolf_22
Would searching for the string "&$" work if I'm searching for all call-by-reference actions pertinent to PHP < 5.3?
This may be a stupid move on my part, but due to restrictions on making the development environment identical to the production, I plan on using GREP to replace all "&$" with just "$". That should be a good enough band aid to continue development, right?
What would the cons be in doing this?
Re: Search String
Posted: Thu Oct 01, 2009 1:38 pm
by requinix
(it's called "call-time pass-by-reference")
That would also catch
Code: Select all
$var=&$othervar;
array($var, &$othervar);
A better match would be
Code: Select all
\b(?!array)(\w+\s*)\(([^)]*?)(^|,)(\s*)&(\s*)\$
to be replaced with
Emphasis on "better", as in "not necessarily perfect".
Honestly, I'd rather fix each occurrence as PHP finds it - then there's no risk of accidentally screwing up code.
Re: Search String
Posted: Thu Oct 01, 2009 1:45 pm
by Wolf_22
tasairis wrote:(it's called "call-time pass-by-reference")
Ah, I see...
tasairis wrote:Honestly, I'd rather fix each occurrence as PHP finds it - then there's no risk of accidentally screwing up code.
Even if there's thousands to fix?

Re: Search String
Posted: Thu Oct 01, 2009 2:00 pm
by requinix
Wolf_22 wrote:tasairis wrote:Honestly, I'd rather fix each occurrence as PHP finds it - then there's no risk of accidentally screwing up code.
Even if there's thousands to fix?

Run your search-and-replace, but be prepared to handle other problems that develop.