我在以前的所有程式中都使用了 ob_start() 和 $output2= ob_get_clean() 但是突然之間,對于當前的程式,我在運行程式時遇到了“未定義變數 $output2”。如果有人看一下,我將不勝感激
代碼:
<ul>
<?php
require_once "classes/DBAccess.php";
// remoteserver I used db.php Elh wants to get database setting from *** for the first time, early bird
include "settings/db.php";
$db = new DBAccess($dsn, $username, $password);
$pdo = $db->connect();
$sql = "select categoryName, categoryId from category";
$stmt = $pdo->prepare($sql);
$rows = $db->executeSQL($stmt);
$rows = $pdo->query($sql);
foreach ($rows as $row):
$id = $row["categoryId"];
$name = $row["categoryName"];
?>
<li><a href="hype.php?id=<?= $id ?>"><?= $name ?></a></li>
<?php endforeach;
ob_start();
$output2= ob_get_clean();
include "templates/layout.html.php";
$pdo = null;
?>
</ul>
uj5u.com熱心網友回復:
輸出緩沖的作業原理是攔截所有輸出;ob_start()截取 ob_end_clear() 和 ob_end_clear()之間的任何內容;之前的任何輸出ob_start()都不是。
在這種情況下,由于 2 個陳述句相互跟隨,因此您根本沒有攔截任何內容。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/390178.html
