Argument

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2006
Jamie
 
Posts: n/a
Default Argument

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
Reply With Quote
  #2 (permalink)  
Old 04-20-2006
fletch
 
Posts: n/a
Default Re: Argument

> 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?

Reply With Quote
  #3 (permalink)  
Old 04-21-2006
Jamie
 
Posts: n/a
Default Re: Argument

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:12 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0