期末复习
关于类的问题(1)
例:
<?
class test{
var $a,$b;
function test($a,$b){
$this->a=$a;
$this->b=$b;
}
关于类的问题(2)
function getA(){
return $this->a;
}
function getB(){
return $this->b;
}
function xprint(){
echo "a=".$this->a." b=".$this->b;
}
};
关于类的问题(3)
class test1 extends test{
var $c,$d;
function test1($a,$b,$c,$d){
$this->a=$a;
$this->b=$b;
$this->c=$c;
$this->d=$d;
}
关于类的问题(4)
function getC(){
return $this->c;
}
function getD(){
return $this->d;
}
关于类的问题(5)
function xprint(){
echo "a=".$this->a." b=".$this->b." c=".$this->c." d=".$this->d;
}
};
$x=new test(0,0);
$x->xprint();
关于类的问题(6)
echo "<br>\n";
$y=new test1(1,2,3,4);
$y->xprint();
?>
运行结果:
a=0 b=0a=1 b=2 c=3 d=4
上例说明:类具有多态性和单继承性。
在PHP中类不能多继承,类中函数也不能重载。
试题示例(1)
选择题:
:
(A)chdir (B)cd (C) opendir (D)rmdir
2. PHP中用来删除当前目录的函数是:
(A)chdir (B)cd (C) opendir (D)rmdir
试题示例(2)
填空题
。请填空【1】。<? $myFile = 【1】; if(!($myFile)) { echo "file could not be opened"; exit; }
试题示例(3)
for($index=0; $index<10; $index++) { fputs($myFile, "line $index\n"); } fclose($myFile);?> 【1】答案:
PHP培训课件★review 来自淘豆网m.daumloan.com转载请标明出处.