dsfs21312 2013-05-10 18:28
浏览 64
已采纳

PHP无法在WAMP上找到LESS文件,但可以在服务器上找到

I'm trying to use lessphp on WAMP for local development. I'm trying to preprocess a particular less file on WAMP that is right next to the PHP file, but PHP throws errors saying it cannot find my "input.less" file. When I upload the same set of files to my server, PHP can find the less file and preprocess it just fine.

Is there a setting in my WAMP's php.ini that I need to change for it to be able to find files?

My php file:

<?php
    require "lessc.inc.php";
    $less = new lessc;
    $input = "input.less";
    $less_code = file_get_contents("input.less");
    echo $less->compile($less_code);
?>

My less file:

div {
    border:5pt red dashed;
}

The offending error:

( ! ) Warning: file_get_contents(input.less) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in F:\Freelance\server\wamp\www\theming\wp-content\themes\spiralkit\header.php on line 51
  • 写回答

1条回答 默认 最新

  • dongmiao260399 2013-05-10 21:21
    关注

    You could try the actual __ DIR __ constant in PHP.

    __ DIR __ : The directory of the file. If used inside an include, the directory of the included file is returned.

    PS: Remove the whitespaces

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件