Caucho Forums  

This forum is permanently closed because of spam. For free community support, please visit Google Groups:


Go Back   Caucho Forums > Quercus

Reply
 
Thread Tools Display Modes
  #1  
Old 04-01-2010, 06:05 AM
juancho_h juancho_h is offline
Junior Member
 
Join Date: Nov 2009
Location: Mar del Plata, Buenos Aires, Argentina
Posts: 6
Unhappy Param By Reference

Hi, I have a little problem.
I'm re-writing some functions from PHP to Java, and i need to use params by reference. There is any chance to do that?

Thanks..
Reply With Quote
  #2  
Old 04-01-2010, 04:41 PM
nam nam is offline
Administrator
 
Join Date: Aug 2009
Posts: 337
Default

You can pass a reference to any Java function by annotating the argument with @Reference

com.caucho.quercus.annotations.Reference
Reply With Quote
  #3  
Old 06-01-2010, 09:35 AM
sblommers sblommers is offline
Member
 
Join Date: Nov 2009
Location: Almere, The Netherlands
Posts: 32
Exclamation difference var_dump results when using references

Code:
$var=array('a'=>array(1,2,3),'b'=>array(4,5,6));

foreach ($var as &$sub) {
  foreach ($sub as &$element) {
    $element=$element+1;
  }
}

var_dump($var);
OUTPUT APACHE+PHP
Code:
array(2) {
  ["a"]=>
  array(3) {
    [0]=>
    int(2)
    [1]=>
    int(3)
    [2]=>
    int(4)
  }
  ["b"]=>
  &array(3) {
    [0]=>
    int(5)
    [1]=>
    int(6)
    [2]=>
    &int(7)
  }
}
OUTPUT QUERCUS
Code:
array(2) {
  ["a"]=>
  &array(3) {
    [0]=>
    &int(2)
    [1]=>
    &int(3)
    [2]=>
    &int(4)
  }
  ["b"]=>
  &array(3) {
    [0]=>
    &int(5)
    [1]=>
    &int(6)
    [2]=>
    &int(7)
  }
}
Doesn't this have any side-effects when looping another nest?

Sebastiaan

Last edited by sblommers; 06-01-2010 at 09:40 AM.
Reply With Quote
  #4  
Old 06-19-2010, 05:17 AM
juancho_h juancho_h is offline
Junior Member
 
Join Date: Nov 2009
Location: Mar del Plata, Buenos Aires, Argentina
Posts: 6
Default

Quote:
Originally Posted by nam View Post
You can pass a reference to any Java function by annotating the argument with @Reference

com.caucho.quercus.annotations.Reference
Sorry I totally forgot about this post. Thanks for your help it works just perfect!
The only thing is that if I pass a literal value instead of a var it should throw an error, but there is not error.
Reply With Quote
  #5  
Old 06-19-2010, 05:20 AM
juancho_h juancho_h is offline
Junior Member
 
Join Date: Nov 2009
Location: Mar del Plata, Buenos Aires, Argentina
Posts: 6
Smile

Quote:
Originally Posted by nam View Post
You can pass a reference to any Java function by annotating the argument with @Reference

com.caucho.quercus.annotations.Reference
Sorry I totally forgot about this post. Thanks for your help it works just perfect!
The only thing is that if I pass a literal value instead of a var it should throw an error, but there is not error.
Reply With Quote
Reply

Tags
by reference, parameters, php, quercus

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:15 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.