class Car {
function __construct() {
print "构造函数被调用 \n";
}
function __destruct() {
print "析构函数被调用 \n";
}
}
$car = new Car(); //实例化时会调用构造函数
echo '使用后,准备销毁car对象 \n';
unset($car); //销毁时会调用析构函数
理解这些就行了楼上的
function __construct() {
print "构造函数被调用 \n";
}
function __destruct() {
print "析构函数被调用 \n";
}
}
$car = new Car(); //实例化时会调用构造函数
echo '使用后,准备销毁car对象 \n';
unset($car); //销毁时会调用析构函数
理解这些就行了楼上的
2015-11-18
<?php
class Car {
public $speed = 10;
public function speedDown($name,$args){
if($name == 'speedDown'){
return $this->speed -= $args;
}
return null;
}
}
$car = new Car();
$car->speedDown('speedDown',10); //调用不存在的speedDown方法
echo $car->speed;
class Car {
public $speed = 10;
public function speedDown($name,$args){
if($name == 'speedDown'){
return $this->speed -= $args;
}
return null;
}
}
$car = new Car();
$car->speedDown('speedDown',10); //调用不存在的speedDown方法
echo $car->speed;
2015-11-18
<?php
class Car {
function speedUp(){
$num = rand(1,25);
$speed = 60;
while($speed<=125){
$speed = $speed + $num;
}
$this->speed = $speed;
return "你已经超速,速度为:".$speed;
}
}
$car = new Car();
echo $car->speedUp();
echo "<br/>";
echo $car->speed;
?>
class Car {
function speedUp(){
$num = rand(1,25);
$speed = 60;
while($speed<=125){
$speed = $speed + $num;
}
$this->speed = $speed;
return "你已经超速,速度为:".$speed;
}
}
$car = new Car();
echo $car->speedUp();
echo "<br/>";
echo $car->speed;
?>
2015-11-17
$dir = '/data/webroot/usercode/code';
if (!is_readable($dir)) {
foreach (glob($dir.'/*') as $file) {
if (file_exists($file)) {
unlink($file);
} else {
echo '文件不存在';
}
}
} else {
echo '文件夾只讀,不能刪除';
}
if (!is_readable($dir)) {
foreach (glob($dir.'/*') as $file) {
if (file_exists($file)) {
unlink($file);
} else {
echo '文件不存在';
}
}
} else {
echo '文件夾只讀,不能刪除';
}
2015-11-17