[Class] "global" again, not working?

From: Date: Wed, 14 Aug 2002 20:53:16 +0000
Subject: [Class] "global" again, not working?
Groups: php.general 
Request: Send a blank email to php-general+get-112599@lists.php.net to get a copy of this message
Hi people, Again, a problem with "global". Maybe you can shed a light on this one... Consider this part of a class (with [...] I marks things I left out, which aren't important for the problem, FAFAIK): class FotoView { [...] var $fotos; var $cats; var $start; var $limiet; [...] /** * Constructor */ function FotoView($start,$cats=NULL,$admin=FALSE) { $this->limiet = $this->getLimit(); [...] $this->start = $start; [...] echo("1:".$this->start." ".$this->limiet); $this->fotos = $this->findFotos(); } function getLimit() { global $WORKDIR; include_once($WORKDIR."obj/dbconnection.obj.php"); $db = new DBConnection(); $result = $db->query("SELECT lijst_x, lijst_y FROM config"); $data = mysql_fetch_row($result); return ($data[0]*$data[1]); } [...] function findFotos() { global $start, $cats, $limiet, $urlfotoview, $WORKDIR; echo("2:".$this->start." ".$this->limiet); echo("3:".$start." ".$limiet); [...] Okay, $WORKDIR is set in the page that calls this class, it works (checked it). You can see three echo's in there. The result from those are: 1: 0 20 2: 0 20 3: 0 Can anyone explain to me why in findFotos() the defining of $limiet doesn't work correctly? Why isn't a reference made to $this->limiet? I'm really at a lost, here... Any help is appreciated! -- Kind regards, Tim

« previous php.general (#112599) next »