fubowl Posted August 2, 2007 Share Posted August 2, 2007 Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in ... I came across this in a script I just purchased. This is the second time in a week I've come across it. I know this error is caused by using &$somevar , and my question is what did this used to do? When I search for it I only come up with answers on how to allow Call-time pass-by-reference in the ini as a language option. But still, what the hell is the ampersand supposed to do!??! Thanks. Quote Link to comment Share on other sites More sharing options...
btherl Posted August 2, 2007 Share Posted August 2, 2007 Try the following: $a = 1; foo(&$a); print "a = $a\n"; bar($a); print "a = $a\n"; function foo(&$a) { $a = $a + 1; } function foo($a) { $a = $a + 1; } When $a is passed by reference and modified inside the function, the original copy is modified too. They are the same variable. But if it is passed by value (the default behaviour) then only the copy inside the function is modified. You should probably ask the script's vendor for advice on what to do. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 2, 2007 Share Posted August 2, 2007 you appear to have a script built for php4 running on a php5 box (I love 5!) passing by reference means you actually pass the entity itself (any manipulation done in the function would affect the entity and not a COPY of the entity). fsockopen has absolutley no requirement to recieve anything by reference so where ever you see & used inside fsockopen just delete the &! Quote Link to comment Share on other sites More sharing options...
fubowl Posted August 2, 2007 Author Share Posted August 2, 2007 So if referencing is built for php4, how do you get btherl's example to run without error. I'll just remove it in my fsocket function but how would you write it for all it's other uses? Quote Link to comment Share on other sites More sharing options...
btherl Posted August 2, 2007 Share Posted August 2, 2007 referencing isn't built for php4, it just has slightly different rules between php4 and 5. There was a typo in my example. After fixing that, it works the same in both 4 and 5. $a = 1; foo(&$a); print "a = $a\n"; bar($a); print "a = $a\n"; function foo(&$a) { $a = $a + 1; } function bar($a) { $a = $a + 1; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.