PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

php的io操作解决思路

原创
2016-06-13 13:36:12 803浏览

php的io操作

C# code

 public static void WriteLog(string msg) {
            using (System.IO.StreamWriter reader = new System.IO.StreamWriter(System.Web.HttpContext.Current.Server.MapPath("~/log.txt"), true, Encoding.UTF8)) {
                reader.WriteLine(msg + "\t" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
        }

 



我绝望了 不设断点了 写在记事本算了 

php的io不熟 那位大侠把这个转成等效的php代码啊

------解决方案--------------------
file_put_contents( realpath('~/log.txt'), $msg . date('Y-m-d H:i:s));

------解决方案--------------------

代码很简洁啊
------解决方案--------------------
探讨

file_put_contents( realpath('~/log.txt'), $msg . date('Y-m-d H:i:s));

------解决方案--------------------
探讨
文件不存在不会自动创建?
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。