VAR and variables
| From: | Matt | Date: | Thu, 25 Jan 2001 21:00:09 +0000 |
| Subject: | VAR and variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-36700@lists.php.net to get a copy of this message | ||
I have a question that may seem kind of silly, but I'm curious...
When using PHP why would one use "var" to define a variable as opposed to just regularly creating it?
For example, if I have a class defined as below:
<pre>
class Simple {
var $a;
function Simple() {
$this->a = 5;} function first() {
return $this->a;} } </pre> This class, when created, sets the variable $a to 5, and the function first returns the value in $a.... my question is could I omit the var and still have it function in this fashion? What is the purpose of it? Also, can I access this variable through the same -> convention, i.e. would the following be allowed? <pre> $test = new Simple(); echo $test->a; </pre> Thanks.