Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
回显php代码错误?_Php_Html - Fatal编程技术网

回显php代码错误?

回显php代码错误?,php,html,Php,Html,我的问题是,当我回显我的php代码时,它不会回显它回显的代码。作为回报,我正在尝试向我的网站添加一个php代码,这样每周网站上的文本都会从存储的文件(如quotes.txt)更新。我的php有什么问题吗?有什么建议吗?下面是发生的情况的屏幕截图 我的代码: <div class="wrapper"> <div class="teachings"> <h1 id="teach">Teaching's<

我的问题是,当我回显我的php代码时,它不会回显它回显的代码。作为回报,我正在尝试向我的网站添加一个php代码,这样每周网站上的文本都会从存储的文件(如quotes.txt)更新。我的php有什么问题吗?有什么建议吗?下面是发生的情况的屏幕截图

我的代码:

        <div class="wrapper">
        <div class="teachings">
            <h1 id="teach">Teaching's</h1>
            <hr>
            <?php 
$text = file_get_contents("quotes.txt");  
$text = trim($text); //This removes blank lines so that your 
//explode doesn't get any empty values at the start or the end.     
$array = explode(PHP_EOL, $text);
$lineNumber = date('s');

echo "<p>$lineNumber</p>";
?>
            <h1>Weekly Teachings :</h1>
            <br>
        </div>
    </div>

教学的


您正在回显
日期('s')
函数调用中的currect second值

我假设您要回显数组中的行数

$array = explode(PHP_EOL, $text);
$lineNumber = count($array);

echo "<p>$lineNumber</p>";
$array=explode(PHP\u EOL,$text);
$lineNumber=计数($array);
回声“$lineNumber

”;
但如果你有其他意图,请添加一条评论,我将尝试相应地更改此答案

回复:你的评论如下,那么你想做什么

echo "<p>{$array[0]}</p>";
echo“{$array[0]}

”;
您要做的是

echo $array[$lineNumber];

这将回显行号为周号的报价。

$lineNumber=date('s')然后回显
回显“$lineNumber

你期望得到什么happen@RiggsFolly无需在此处喊叫…查看
文件
函数。不需要
文件获取内容
分解
。我想您需要
$lineNumber=date('W');回显“”.$array[$lineNumber]。

trim
不会删除空行,它只是删除内容前后的
空格
-字符。嘿@riggsfully我想我不支持我想做的事情,但我每周都尝试在quotes.txt中回显文本,文本已经存储在quotes.txt中,但我将日期改为s,因为我想测试它。因此,基本上php代码在quotes.txt中占据第一行,echo在该周的网站上发布了它,并且每周都会继续运行。请参阅其他建议,但我仍然存在每秒钟或每分钟更新一次以测试它是否有效的问题@Riggsfollith这不是这个问题的一部分。所以,再问一个关于这个主题的问题