In the following sample what does var do?
Does it instantiate the variable?PHP Code:class someclass {
var $something;
}
Wouldn't you just say the following to make it exist?
I am really confused.PHP Code:class someclass {
$something;
}
| SitePoint Sponsor |
In the following sample what does var do?
Does it instantiate the variable?PHP Code:class someclass {
var $something;
}
Wouldn't you just say the following to make it exist?
I am really confused.PHP Code:class someclass {
$something;
}
Dave Merwin





You declare variables that way. By doing that outside you make the variable accessible from any method inside the class:
SillyPHP Code:
class Something {
var $something;
function Something($something)
{
$this->something = $something;
}
function somethingElse()
{
//look i can access that variable from here
return $this->something;
}
}
I'm sorry, but I just got the anthology (PHP ANTHOLOGY). I do not understand your example. To save you all the hard work... is this correct?
Class = stores many functions and methods
Function = does one thing
Method = the way that thing is done
My comments are in your code.
Is that right?Originally Posted by Sillysoft
Dave Merwin
Bookmarks