About passing values by reference:
function test_reference_in(&$array) { $array['a'] = 2; } $test_array['a'] = 1; test_reference_in($test_array); echo $test_array;
About nusoap:
Now in nusoap the client class is nusoap_client .
In this class, you have nusoap_client::call() to make a soap call.
This is what appen in nusoap_client::call() for the $params array, which is your $sendParams in your example.
I am going to omit all other methods that are not related to $params in order to better explain what is happening.
function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
So, as you can see here, there are no advantages to passing $ params by reference.
Because:
- $ params is in no way modified in nusoap_client :: call ()
- Even if you change $ params somewhere else after you have to use nusoap_client :: call () again
What if you want to pass $ params by reference anyway? Can I do it?
Well yes you can!
To do this, you need to copy nusoap_client.php and call it nusoap_client_new.php .
There, change the form of the class name nusoap_client to nusoap_client_new .
Modify the nusoap_client_new::call() method by adding ref to params as follows:
function call($operation,&$params = array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){ }
At the end, update your code to require and use nusoap_client_new::call() instead of nusoap_client::call() .