Alucni test su php e classi. No array
This commit is contained in:
82
php3.php
Normal file
82
php3.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
include_once "php2.php";
|
||||
|
||||
|
||||
$gino = new b("a","b","c");
|
||||
$gino->get_constant_a();
|
||||
echo $gino::A;
|
||||
|
||||
a::$alfio = 2;
|
||||
echo a::$alfio;
|
||||
echo b::get_alfio();
|
||||
|
||||
|
||||
|
||||
class a {
|
||||
|
||||
const A = "mario";
|
||||
const B = "mariob";
|
||||
|
||||
public $a;
|
||||
public $b;
|
||||
|
||||
static public $alfio;
|
||||
|
||||
public function __construct ($i1,$i2){
|
||||
$a=$i1;
|
||||
$b=$i2;
|
||||
}
|
||||
|
||||
|
||||
public function get_constant_a (){
|
||||
|
||||
|
||||
echo self::A;
|
||||
|
||||
}
|
||||
|
||||
public function test (){
|
||||
print "ale";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class b extends a{
|
||||
|
||||
const A = "sa";
|
||||
const B = "sas";
|
||||
|
||||
public $c;
|
||||
|
||||
static public $alfio;
|
||||
|
||||
public static function get_alfio(){
|
||||
return parent::$alfio;
|
||||
}
|
||||
|
||||
public function __construct ($i1,$i2,$i3){
|
||||
parent::__construct($i1,$i2);
|
||||
$c=$i3;
|
||||
}
|
||||
|
||||
|
||||
public function get_constant_a (){
|
||||
|
||||
|
||||
echo parent::get_constant_a ();
|
||||
self::test();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user