Re: class and global

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok, i've found a workaround. So contrary to what is stated apparently
in the documentation I had to declara the variables explicitely
"global" to make it working and to create the object and assign
_without_ reference.

to sum up :

global $freedb;
$freedb = new freedbaxs();
function return_freedb_search($array)
{
    global $freedb;
   [snip]
         $freedb->freedb_search($txt);
}

this is the one working.


On Sun, 20 Mar 2005 11:37:53 +0000, Mister Jack <pooly7@xxxxxxxxx> wrote:
> Ok, I've tried with a dummy class :
> 
> class dummy {
>         var $yank;
>         Function dummy()
>         {
>                 $this->yank = "test dummy";
>         }
> }
> 
> and the problem is exactly the same.
> i've done
> print_r($dummy);
> is works ok outside the function, but inside print_r($dummy) doesn't
> return anything, like $dummy wasn't existing, even tough I declared it
> to be global... So the class n itself doesn't have anything to do with
> it.
> I'm really stuck with this. Is there any incompatibiliy with class and
> global declaration ?
> btw, I'm using PHP 4.3.10-8
> thanks for your help,
> 
> 
> On Sat, 19 Mar 2005 20:45:55 +0000, Mister Jack <pooly7@xxxxxxxxx> wrote:
> > there is no database connection involved here. if I displace the
> > $freedb =& new freedbaxs();
> > inside the function it's works.
> >
> > I should give a try with a dummy object. (but the constructor, only
> > initialize empty array)
> >
> > On Sat, 19 Mar 2005 21:17:02 +0200, BAO RuiXian <ruixian.bao@xxxxxxxxxx> wrote:
> > >
> > >
> > > Evert - Rooftop Solutions wrote:
> > >
> > > > pooly wrote:
> > > >
> > > >> I'm trying to use a global object (declared at a upper level), but
> > > >> all I got is :
> > > >> Call to a member function on a non-object in
> > > >> /home/pooly/public_html/templeet/modules/freedb.php on line 16
> > > >>
> > > Hmm, perhaps your problem is the failed connection to your database. Can
> > > you verify this?
> > >
> > > Best
> > >
> > > Bao
> > >
> > > >> part of the code is :
> > > >> $freedb =& new freedbaxs();
> > > >> Function return_freedb_search($array)
> > > >> {
> > > >>     global $freedb;
> > > >>     [snip]
> > > >>         $freedb->freedb_search($txt);
> > > >>
> > > >>
> > > > I don't see an error in this code, perhaps you should give us a bit
> > > > more information.
> > > >
> > > > grt,
> > > > Evert
> > > >
> > > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux