已采纳回答 / iYun
printf — 输出格式化字符串函数说明int printf ( string $format [, mixed $args [, mixed $... ]] )依据 format 格式参数产生输出。
2016-04-10
最赞回答 / 声声慢
<?php//定义一个方法:funcfunction func() {echo 'exists';}//将方法丢给一个变量:$name$name = 'func'; //判断函数是否存在if ( function_exists('func')) { //执行方法:func, 定义变量$sb接受返回值,但是func没有返回东西,索引 $sb是空的 $sb=func();}?>
2016-04-09
if(file_exists($filename)){
if ( is_writeable($filename) ) {
$data = 'hello';
file_put_contents($filename,$data);
}
}
if ( is_writeable($filename) ) {
$data = 'hello';
file_put_contents($filename,$data);
}
}
2016-04-08
$str = serialize($a); //对象序列化成字符串
echo $str.'<br>';
$c = unserialize($str,true); //反序列化为对象
var_dump($c);
echo $str.'<br>';
$c = unserialize($str,true); //反序列化为对象
var_dump($c);
2016-04-08
$str = json_encode($a); //对象序列化成字符串
echo $str.'<br>';
$c = json_decode($str,true); //反序列化为对象
var_dump($c);
echo $str.'<br>';
$c = json_decode($str,true); //反序列化为对象
var_dump($c);
2016-04-08
class Truck extends Car{
public function speedUp(){
parent::speedUp();
$this->speed+=50;
return $this->speed;
}
}
public function speedUp(){
parent::speedUp();
$this->speed+=50;
return $this->speed;
}
}
2016-04-08
//定义继承于Car的Truck类
class Truck extends Car{
public function speedUp(){
$this -> speed = parent::speedUp()+50;
return $this ->speed;
}
}
class Truck extends Car{
public function speedUp(){
$this -> speed = parent::speedUp()+50;
return $this ->speed;
}
}
2016-04-07