【问题标题】:Assigning a variable equal to Include function content分配一个等于 Include 函数内容的变量
【发布时间】:2012-05-13 15:41:54
【问题描述】:

我在 vBulletin 系统中遇到了这个问题。我想在侧边栏区域构建一个块来帮助我完成一些日常工作。我写了这样的 php 代码:

<?php
    $myDay = date('D');
    $myHour = date('G');
    // Saturday
    if ($myDay == "Sat") {
        if ($myHour >= 7) {
            $output = include('textFilePath/saturday.txt');
        } else {
            $output = include('textFilePath/friday.txt');
        }
    }
    // Sunday
    if ($myDay == "Sun") {
        if ($myHour >= 7) {
            $output = include('textFilePath/sunday.txt');
        } else {
            $output = include('textFilePath/saturday.txt');
        }
    }
    // and it goes on to friday...
    // and in the end :
    return $output;
?>

我的问题在于 include() 函数。当我返回 $output 值时,它返回一个布尔值(0 或 1)并包含函数在文档开头写出 txt 文件内容而不是“侧边栏块” 我知道我可以回显实际内容,而不是使用包含和 txt 文件。但正如我所说,我想自动化日常任务并让用户有权编辑 txt 文件。

是否有任何其他技术或功能可以将本地文件的内容分配给变量?

【问题讨论】:

    标签: php sidebar vbulletin


    【解决方案1】:

    您可能需要检查

    $output = file_get_contents('textFilePath/saturday.txt');
    

    更多信息在这里:http://in3.php.net/file_get_contents

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-10
      • 2019-08-22
      相关资源
      最近更新 更多