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
Error:wrong
#0 {main}
异常行号:3
所在文件:/26/603/8whB/index.php
Warning: file_put_contents(error.log): failed to open stream: Read-only file system in /26/603/8whB/index.php on line 11
#0 {main}
异常行号:3
所在文件:/26/603/8whB/index.php
Warning: file_put_contents(error.log): failed to open stream: Read-only file system in /26/603/8whB/index.php on line 11
2016-04-07
默认都为public,外部可以访问。一般通过->对象操作符来访问对象的属性或者方法,对于静态属性则使用::双冒号进行访问。当在类成员方法内部调用的时候,可以使用$this伪变量调用当前对象的属性。
2016-04-06