【问题标题】:php comment script from gentle source not working on 000webhost free server来自温和来源的 php 评论脚本无法在 000webhost 免费服务器上运行
【发布时间】:2013-11-05 18:07:54
【问题描述】:

索引.php

<?php include './include.php'; ?>
<html> Page data
<?php echo $c5t_output; ?>
 </html>

include.php

<?php

    /** 
     * GentleSource Comment Script
     * 
     */

    define('C5T_ROOT', '/comment_script_2.1.2/');
    include C5T_ROOT . 'comment.php'; 


    ?>

当我在页面上加载脚本时出现以下错误 000webhost.com 免费服务器,说 index.php 但它在我的本地 xampp 服务器上完美运行,即使该文件位于正确的位置并具有正确的文件名。

警告:include() [function.include]:无法打开“/comment_script_2.1.2/comment.php”以包含(include_path='.:/usr/lib/php:/usr/local/lib/php' ) 在 /home/a5962782/public_html/include.php 第 9 行

【问题讨论】:

  • 一些路径错误,请仔细检查。
  • 我想知道你的常数是否应该是相对的?在这种情况下,它应该是'./comment_script_2.1.2/',即以点为前缀。就目前而言,它希望该文件夹位于文件系统的根目录,您可能在本地计算机上拥有该文件夹 - 如果是这样,它位于错误的位置 - 但在共享托管服务提供商上这是不可能的。

标签: php


【解决方案1】:

发件人:http://php.net/manual/en/function.include.php

如果定义了路径——无论是绝对路径(在 Windows 上以驱动器号或 \ 开头,或在 Unix/Linux 系统上以 / 开头)还是相对于当前目录(以 . 或 .. 开头)——include_path 都将被忽略共。例如,如果文件名以 ../ 开头,解析器将在父目录中查找请求的文件。

您在包含中定义了一个绝对路径。删除 / 它应该可以工作。

define('C5T_ROOT', 'comment_script_2.1.2/');
include C5T_ROOT . 'comment.php'; 

这将使包含看起来在您的包含路径中,其中包含您的当前目录 (.)。所以./comment_script_2.1.2/comment.php 会被拾取。

【讨论】:

    猜你喜欢
    • 2015-08-06
    • 2015-09-02
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 2014-10-10
    • 1970-01-01
    • 2023-03-19
    相关资源
    最近更新 更多