Stickybomb Posted September 28, 2007 Share Posted September 28, 2007 hi i am currently trying to laern more about php witch inlcudes trying to work with its oop form. I have come across a few instances where there have been either variables,functiions or methods prepended with either the @ or &. can anyone explain these uses for example i seen something like this @mail ($variable,$variable,$variable) and i have seen this function showBox(&$connector){ //do something return result } what are the meanings of these and the specific uses please Link to comment https://forums.phpfreaks.com/topic/71045-solved-leading-characters/ Share on other sites More sharing options...
KevinM1 Posted September 28, 2007 Share Posted September 28, 2007 hi i am currently trying to laern more about php witch inlcudes trying to work with its oop form. I have come across a few instances where there have been either variables,functiions or methods prepended with either the @ or &. can anyone explain these uses for example i seen something like this @mail ($variable,$variable,$variable) and i have seen this function showBox(&$connector){ //do something return result } what are the meanings of these and the specific uses please The '@' tells PHP to not display any errors the function may generate. The '&' signifies that the variable is being passed-by-reference to the function. More generically, the '&' always means treat whatever it's attached to like a reference. So, you can return values by reference, too. This link explains what references are and how PHP uses them: http://us2.php.net/references EDIT: In PHP 5, everything is pass-by-reference by default, so you don't have to use the '&' to signify it. Link to comment https://forums.phpfreaks.com/topic/71045-solved-leading-characters/#findComment-357250 Share on other sites More sharing options...
Stickybomb Posted September 28, 2007 Author Share Posted September 28, 2007 ok so & is basically like saying that no matter where the varible is updated give it the most recent value so for instance $bar = 6 $foo = $bar $bar = 12 print $foo // 6 $bar = 6 $foo = &$bar $bar = 12 print $foo // 12 if this is correct, then is this affected by scope? or is it referenced by document Link to comment https://forums.phpfreaks.com/topic/71045-solved-leading-characters/#findComment-357286 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.