php - LESS.php - 它在哪里保存编译后的文件?

标签 php html css twitter-bootstrap less

我正在尝试设置一个 PHP LESS 解析器:less.php ( https://github.com/oyejorge/less.php#basic-use )。

我已经根据示例编写了基本代码:

<?php
  require_once 'less.php/Less.php';

  $parser = new Less_Parser();
  $parser->parseFile( 'Z:\home\test1\www\assets\bootstrap\less\bootstrap.less', 'test' );
  $css = $parser->getCss();
?>

应该从给定的文件夹编译 bootstrap.less 文件。它可以正常工作,但是我不确定将编译的 css 文件保存在哪里?我可以指定它的目的地吗?任何帮助将不胜感激。

最佳答案

根据其文档,getCss 不保存 CSS。事实上,变量 $css 将包含 CSS。要将 $css 的值写入磁盘,请使用例如 file_put_contents。即:

<?php
require_once 'less.php/Less.php';

$parser = new Less_Parser();
$parser->parseFile( 'Z:\home\test1\www\assets\bootstrap\less\bootstrap.less', 'test' );
$css = $parser->getCss();

// And now to write the contents:
file_put_contents("output.css", $css);
?>

关于php - LESS.php - 它在哪里保存编译后的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39838660/

相关文章:

php - PHP 中的 iOS 收据验证

php - Redis for php 5.4 在 Windows 机器中找不到 fatal error 类 'Redis'

javascript - 选择框在转换后在 Firefox 中移动 :scale()

javascript - 如何在 Angular.js 中编写指令以从 dom 中抓取数据

html - 相同的部分在两个相同的应用程序中表现不同

php - Laravel - 任务调度

java - MySQL 数据未显示在 Android RecyclerView 中(Logcat 错误 : Couldn't load memtrack module)

html - 按钮内文本周围带有圆 Angular 的矩形框

CSS 保存图像长宽比

javascript - 选择一个重叠的 div