摘要:<?phpdate_default_timezone_set('Etc/GMT-8');class obj{ public $time=''; public $oper=''; public $arr=['登陆','修改密码','
<?php
date_default_timezone_set('Etc/GMT-8');
class obj
{
public $time='';
public $oper='';
public $arr=['登陆','修改密码','退出登陆'];
public function __construct()
{
$this->time=date('y-m-d h:i:s');
$this->oper=$this->arr[rand(0,2)];
$arr=['0'=>$this->time,'1'=>$this->oper];
$str=serialize($arr);
var_dump($arr);
echo '<br>';
var_dump($str);
echo '<br>';
var_dump(file_put_contents('./files/demo5.log',$str));
echo '<br>';
}
}
new obj;
$arr=file_get_contents('./files/demo5.log');
var_dump($arr);
echo '<br>';
var_dump(unserialize($arr));
file_put_content()和file_get_content()不需要打开文件就可以直接操作。 serialize()和unserialize()是序列化和反序列化数组或对象,用于put进文件
批改老师:天蓬老师批改时间:2018-12-24 13:06:41
老师总结:file_put_content(), 这样的函数 ,也是做整站 静态化常用的函数