PHP写入日志文件

/** * 写入文件 * $pay_type 文件名 * $content 内容(string类型) */ public static function dingding_log($pay_type,$content){ $filename =$_SERVER['DOCUMENT_ROOT']. '/log/'; $filename = $filename.$pay_type.date('Y-m-d').'.txt'; if (!file_exists($filename)) { //检查是否有该文件夹,如果没有就创建,并给予最高权限 touch($filename, 0777,true); } $Ts=fopen($filename,"a+"); fputs($Ts,"执行日期:"."\r\n".date('Y-m-d H:i:s',time()). ' ' . "\n" .$content."\n"); fclose($Ts); return 'ok'; }
点赞
收藏

评论区

加载中...

相关推荐

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

ThinkPHP 5.0.x 反序列化漏洞 PoC

因为写入的文件名包含特殊符号,所以该漏洞只能在Linux中写入webshell,不能在Windows系统写入。这个漏洞的重点在于体会ThinkPHP的反序列化利用链。演示环境:Kali、ThinkPHP/5.0.24演示代码:application/index/controller/Index.php<?p

Spinner使用

1.在xml文件设立布局文件<Spinner    android:layout\_width"wrap\_content"    android:layout\_height"wrap\_content"    android:layout\_below"@id/b1"    andro

301跳转,文件

<IfModulemod\_rewrite.cRewriteEngineonRewriteCond%{REQUEST\_FILENAME}!dRewriteCond%{REQUEST\_FILENAME}!fRewriteRule^(.\)$index.php/$1\QSA,PT,L\Rewrite

PHP的$_SERVER数组字段详解

$\_SERVER\'PHP\_SELF'\当前正在执行脚本的文件名,与documentroot相关。$\_SERVER\'argv'\传递给该脚本的参数。$\_SERVER\'argc'\包含传递给程序的命令行参数的个数(如果运行在命令行模式)。$\_SERVER\'GATEWAY\_INTERFACE'\

Logstash收集nginx访问日志和错误日志

1、收集访问日志1)、首先是要在nginx里面配置日志格式化输出log_formatmain"$http_x_forwarded_for|$time_local|$request|$status|$body_bytes_sent|$request_body|$content_length|$http_ref