回显 php 代码错误


Echo php code error?

我的事情是当我回显我的php代码时,它不会回显它回显数字的代码作为回报,我正在尝试向我的网站添加一个PHP代码,因此每周网站上的文本都会从存储的文件(如引号.txt(更新。我的 php 有什么问题吗?以下是 https://gyazo.com/fba5fc414228b1ab2a79bb877642477a 发生的事情的屏幕截图

我的代码 :

        <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>

您正在从date('s')函数调用中回显当前第二个值

我假设你想回显数组中的行数

$array = explode(PHP_EOL, $text);
$lineNumber = count($array);
echo "<p>$lineNumber</p>";

但是,如果您打算做其他事情,请添加评论 我将尝试相应地更改此答案

RE:你在下面的评论,那么你想做

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

你想做的是

echo $array[$lineNumber];

这将呼应行号为周数的报价。