View Single Post
Old 04-18-2009, 04:58 PM  
Killswitch - BANNED FOR LIFE
Guest
 
Posts: n/a
Quote:
Originally Posted by KRosh View Post
Why does this work? Why does this show the email address?

#1

Code:
<?php
class person {
    private $email = ?foo?;
    function showEmail() {
        echo $this->email;
    }
}
class user extends person {}
$u = new user();
$u->showEmail();


but this doesn?t?

#2

Code:
<?php
class person {
    private $email = ?foo?;
}
class user extends person {
    function showEmail() {
        echo $this->email;
    }
}
$u = new user();
$u->showEmail();
Also, why does this work

#3

Code:
<?php
class person {
    private $email = ?foo?;
    function showEmail() {
        echo $this->email;
    }}
class user extends person {
    function showEmail() {
        parent::showEmail();
    }
}
$u = new user();
$u->showEmail();

PHP Code:
<?php
class person {
    var 
$email 'foo';
}
class 
user extends person {
    function 
showEmail() {
        echo 
$this->email;
    }
}
$u = new user();
$u->showEmail();
?>
  Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote