Afficher un message
Vieux 10/09/2007, 03h06   #1
Larry Brown
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut accessing one object's attribute from another

Hi all, I've be developing with a structured approach for a long time
and am working at improving my site by adding some classes etc. I
however, am running into an odd thing that I can't figure out what a
reasonable search syntax would yield the desired solution. The problem
is as follows:

class a {

var $thisVar;
...
}

class b {

function hello()
{
echo $first->thisVar;
}
}

$first = new a();
$first->thisVar = "world";

$second = new b();
$second->hello();


There are a number of variables and methods that are common throughout
the user's session that I'm storing in object $first. Class b has
nothing in common with a except that it needs a couple of the variables
stored in the object that is hanging around in the session.

Is $first->thisVar the wrong way to reference that variable? How can I
get to it?

TIA,

Larry


  Réponse avec citation
 
Page generated in 0,04919 seconds with 9 queries