<?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
已采纳回答 / 小灰灰heart
1、void echo ( string $arg1 [, string $... ] )echo 不是一个函数(它是一个语言结构), 因此你不一定要使用小括号来指明参数,单引号,双引号都可以。 echo (不像其他语言构造)不表现得像一个函数, 所以不能总是使用一个函数的上下文。 另外,如果你想给echo传递多个参数, 那么就不能使用小括号。2、int print ( string $arg )print 实际上不是一个函数(它是一个语言结构),因此你可以不必使用圆括号来括起它的参数列表。返...
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