note 89678 deleted from language.oop5.final by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 06:44:23 +0000 |
| Subject: | note 89678 deleted from language.oop5.final by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196620@lists.php.net to get a copy of this message | ||
Note Submitter: sunil dot boodram at gmail dot com
----
Using the scope resolution operator, we can easily access constants, static variables, public
functions and final functions from Final Classes
Note: even by omitting the "public" keyword from the "nightNews()" method, we
can see that the function defaults to public even if prefixed with the keyword final.
<?php
final class news{
const micCheck = "test1"; // will work
static public $promptCheck = "test2"; //will work
//will work
public function morningNews(){
print 'good morning world!';
}
//will work
final public function eveningNews(){
print 'good evening world!';
}
//will work
final function nightNews(){
print 'good night world!';
}
}
print news::micCheck; // output: test1
print '<br/>';
print news::$promptCheck; // output: test2
print '<br/>';
print news::morningNews(); // output: good morning world!
print '<br/>';
print news::eveningNews(); // output: good evening world!
print '<br/>';
print news::nightNews(); // output: good night world!
?>