php的io操作解决思路

WBOY
Release: 2016-06-13 13:36:12
Original
979 people have browsed it

php的io操作

C# code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
 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"));
            }
        }

 

Copy after login


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

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));

------解决方案--------------------
探讨
文件不存在不会自动创建?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template