[PHP] var references question

2004-09-19 Thread Brandon Goodin
Greetings,

 

This is a little difficult to explain. So, below is an example I will work
from. Forgive my ignorance here. I am a java developer using php4 and trying
to figure out a particular scenario.

 

In the following example when I run the myscript.php I pass the $myarr into
the addVal function of the MyClass class. The var_dump in the addVal
function appropriately displays all of the elements of the array a,b,c and
d. However, the var_dump that is done in the script immediately following
the addVal method call displays only elements a,b and c with NO d. From what
I can see, php does not retain the same reference to the array object when
it passes it into the function. It appears that it clones the array and
retains only the changes within the scope of the function. In java I am used
to creating an array and passing it into a method which accomplishes
operations against the array. The passed in array is also modified because
it is a reference to the same array object.

 

Is there a way to accomplish this behavior in php 4?

 

For example:

 

 myscript.php 

 

.

 

$myarr = array();

 

$myarr["valuea"]="a";

$myarr["valueb"]="b";

$myarr["valuec"]="c";

 

$myclass = new MyClass();

$myclass->addVal($myarr);

 

var_dump($myarr);

 

.

 

===end 

 

 

 

 myclass.php 

 

class MyClass {

 

function addVal($myarr){

  $myarr["valued"] = "d";

  var_dump($myarr);

}

 

}

===end 

 

 

Thanks,

Brandon

 



[PHP] PHP 5 and interfaces

2004-04-25 Thread Brandon Goodin
I am looking to port some java code to PHP. I am looking at interfaces in
PHP 5 and wondering if they support 'interface . extends .'. For example I
have interface C and it extends Interface A and B..

 



 

Thanks,

Brandon



[PHP] @session_start()?

2004-04-30 Thread Brandon Goodin
I noticed this notation in one of the PEAR packages @session_start()? What
is the purpose of the '@' sign?

 

Thanks

Brandon