Class parameter vanishes the moment it goes into the class!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    Class parameter vanishes the moment it goes into the class!

    I have a variable with a value that I've verified countless times by
    using both echo and print_r; both indicate the variable exists and has
    a value. The moment I instantiate a class where this variable is
    passed as a parameter, the value literally VANISHES! I cannot figure
    out a way within the "constructo r" of the class to determine if the
    passed parameter has a value since both echo and print_r do not even
    render within there.

    How can I determine my parameter has a value? I tried writing a
    getParameter style function only to again show that there is no value.

    I could produce the class code but it's about 200 lines long, the
    class itself calls about 30 parameters.

    Thanx
    Phil
  • Jeffrey Silverman

    #2
    Re: Class parameter vanishes the moment it goes into the class!

    On Wed, 01 Oct 2003 07:44:44 -0700, Phil Powell wrote:

    <snip!>[color=blue]
    > I could produce the class code but it's about 200 lines long, the class
    > itself calls about 30 parameters.
    >
    > Thanx
    > Phil[/color]

    Not enough information.

    Post code, a code snippet, or a URL to code. If it's long, a URL is
    preferred.
    --
    Jeffrey D. Silverman | jeffrey AT jhu DOT edu
    Johns Hopkins University | Baltimore, MD
    Website | http://www.wse.jhu.edu/newtnotes/

    Comment

    • Janwillem Borleffs

      #3
      Re: Class parameter vanishes the moment it goes into the class!


      "Phil Powell" <soazine@erols. com> wrote in message
      news:1cdca2a7.0 310010644.27564 056@posting.goo gle.com...[color=blue]
      > I have a variable with a value that I've verified countless times by
      > using both echo and print_r; both indicate the variable exists and has
      > a value. The moment I instantiate a class where this variable is
      > passed as a parameter, the value literally VANISHES! I cannot figure
      > out a way within the "constructo r" of the class to determine if the
      > passed parameter has a value since both echo and print_r do not even
      > render within there.
      >
      > How can I determine my parameter has a value? I tried writing a
      > getParameter style function only to again show that there is no value.
      >[/color]

      print_r will show the variable when it is initiated in the constructor.
      Example:

      <?
      class Test {
      var $testparam;

      function Test($testparam ) {
      $this->testparam = $testparam;
      }
      }

      $test = new Test("Hello class");

      print_r($test);

      // Result:
      // test Object ( [testparam] => Hello class )
      ?>

      When you want to retrieve the value of $testparam from within the class, you
      could do either:
      echo $test->testparam;

      Or (and this way is much better)
      through an accessor method in the class which returns $this->testparam


      JW




      Comment

      Working...