Hi,
do
--
echo $data[0]*$data[1]);
return ($data[0]*$data[1]);
--
i think its empty.

In the first place, i thought it was maybe impossible to call a 
class-functions in your constructor. (Cause the class function don't exists 
at the moment you call your constructor).

But the code below showed it isn't that:
<?
class test
{
        var $limiet;

        function test()
        {
                $this->limiet=$this->test2();
        }

        function test2()
        {
                return 5;
        }

    function test3()
    {
        echo 'Limiet:'.$this->limiet;
        return $this->limiet;
    }
}

$TEST= new test();
echo 'Limiet:'.$TEST->test3();
?>

>global $WORKDIR;
NOTE: You should prefer $GLOBALS['WORKDIR'];
read: http://www.php.net/manual/en/migration4.variables.php




Op woensdag 14 augustus 2002 22:53, schreef Tim Stoop:
> 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!

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

Reply via email to