PHP如何创建文件并且写入文字

WBOY
Release: 2016-06-13 12:05:35
Original
1199 people have browsed it

PHP怎么创建文件并且写入文字
我要封装个方法 创建文件并且写入文字 参数2个 width和height

实行后的效果     
比方说如100 300

生成文件名叫s100300.less

里面内容是
@import "shiying";
@screen_width:100px;
@screen_height:300px;


这个函数怎么写。。 红色的要对应哦
------解决方案--------------------

本帖最后由 xuzuning 于 2014-08-27 17:37:16 编辑
function mkless($width, $height) {<br />  $r[] = [email&#160;protected] "shiying";';<br />  $r[] = sprintf([email&#160;protected]_width:%spx;', $width);<br />  $r[] = sprintf([email&#160;protected]_height:$spx;', $height);<br />  file_put_contents("s$width$height.less", join(PHP_EOL, $r));<br />}<br />
Copy after login
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