This is a discussion on Argument within the PHP Language forums, part of the PHP Programming Forums category; Hello Newsgroup, I'm attempting to try some stuff in PHP 4.3.2 (Old.. old version) Basically I have ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello Newsgroup,
I'm attempting to try some stuff in PHP 4.3.2 (Old.. old version) Basically I have something like this: class MyClass { function someMethod($a,$b){ echo "[$a, $b]"; } function foot() { // someMethod sees "Dog","Dog" ????????????? $this->someMethod("Cat","Dog"); $file = $this->filename(); include($file); } } -------------------------------------------- filename.php: html stuff.... this gets included from the foot() method. <?php $this->foot(); ?> --------------------------------------------- In the above code, both $a AND $b are set to "Dog". If I have: someMethod($a, $b = FALSE) { } Both $a and $b are FALSE. The above works fine in PHP 5.n but NOT earlier versions. I've tried other methods, sometimes they work, sometimes not with seemingly little rhyme nor reason. What functions, if any, are causing $a and $b to BOTH be set to "Dog" ??? Jamie -- http://www.geniegate.com Custom web programming guhzo_42@lnubb.pbz (rot13) User Management Solutions |
|
|||
|
> What functions, if any, are causing $a and $b to BOTH be set
> to "Dog" ??? It's a mystery to be sure. I would say that the someMethod("Cat","Dog") is not called if you are not getting the output "[Cat, Dog]". Also I think that the script would produce infinate output since foot() includes a file that calls foot() and you get stuck in a loop. Is this the actual code you are using, or have you tried to make it simpler so that it's more easily understood? |
|
|||
|
In <1145523493.072571.318480@j33g2000cwa.googlegroups .com>,
"fletch" <richard.a.fletcher@googlemail.com> mentions: >> What functions, if any, are causing $a and $b to BOTH be set >> to "Dog" ??? > >It's a mystery to be sure. I would say that the someMethod("Cat","Dog") >is not called if you are not getting the output "[Cat, Dog]". Also I >think that the script would produce infinate output since foot() >includes a file that calls foot() and you get stuck in a loop. > >Is this the actual code you are using, or have you tried to make it >simpler so that it's more easily understood? I tried to simplify it. (I think I screwed up in the example, as it was NOT caught in a loop, in a nutshell, I had: class MyClass { function display(){ include("some_file.php"); } function foot(){ include('foot.php'); } } I tried to reproduce it using a few test files and wasn't able to. where some_file.php accesses '$this->foot()' and foot() in turn access some stuff using vsprintf() among other things. I "fixed" the problem by removing some code in another area that was using references.. (Oh how I miss perl's \$var syntax..) I had: 'function &getParam($name);' that returned a reference to an array element. Anyhow, converting a method that was returning a reference to a method that returns by-value (and just accessing the variables directly when I want a reference) solved it. Albeit in a way that I didn't want. I now have "function getParam($name)" it works. Still, it bugs me that I don't know why the call stack got messed up. Jamie -- http://www.geniegate.com Custom web programming guhzo_42@lnubb.pbz (rot13) User Management Solutions |