Home  >  Article  >  Backend Development  >  php的io操作解决思路

php的io操作解决思路

WBOY
WBOYOriginal
2016-06-13 10:15:141231browse

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


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

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

------解决方案--------------------
探讨
文件不存在不会自动创建?
Statement:
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