Final Keyword
Final Keyword :
Php5
introduces the final keyword , to specify a constant member function or a
constant class. If a member function is declared as “final” that cannot be
overridden in the sub-class.
If a class is declared as final that cannot be
inherited , we cannot create a sub-class for a final class that means after
extends keyword we cannot give a final class.
Constant Function:
Final
function display()
{
}
Constant Class:
Final
class A
{
}
ReferenceTest.php
<?php
class
A{
public $x=11;
}
?>
<?php
$o1
=new A();
$o2=
$o1;
echo
$o1->x."--".$o2->x."<br>";
$o2->x=22;
echo
$o1->x."--".$o2->x;
?>
OutPut:
11--11
22--22
final keyword, of final keyword in, the final keyword, of final keyword, is final keyword, is final keyword in, final keyword for, final keyword in, keyword final.,
0 comments:
Post a Comment