企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
```php //向文件写入信息 file_put_contents(filename,data);//等价于 $fp=fopen(filename,'a');fwrite($fp,data);fclose($fp); //创建文件夹 mkdir(path,0777,true);//path是目录地址,0777是unix权限设置(linux下全部权限,windows会忽略),true意思是可创建多级目录 is_dir() // 判断给定文件名是否是一个目录 rmdir() // 删除目录 //结合上面的几个方法 完成一个打log的方法 //如果路径有中文记得先iconv("UTF-8", "GBK", $path);转码,不然中文会乱码的 function write_log($path,$data){ $filename=basename($path); $pathname=dirname($path); $status=self::log_mkdir($pathname); file_put_contents($pathname.'/'.$filename,$data); } //创建打log的目录 function log_mkdir($pathname){ if(is_dir($pathname)){ return true; }else{ $res=mkdir($pathname,0777,true); return $res; } } ```