【发布时间】:2016-09-18 17:28:27
【问题描述】:
所以我正在学习编写函数。现在我知道如何将内容回显到 foreach 中,但我不知道如何在 foreach 之外打印单行(就像我的表中只有 1 行并且想从中打印 id 和用户名)我该怎么做这个? 我的功能:
public function gegevens(){
$stmt = $this->conn->prepare("SELECT * FROM gegevens_locatie");
$stmt->execute();
$result = $stmt->fetchAll();
//Return result
return $result;
}
当我在我的其他页面上调用该函数时,我调用它:
require_once 'class/class.overig.php';
$overig = new OVERIG();
我已经尝试过 print_r($overig->gevens()) 之类的东西并带有回声,但我似乎无法让它工作。那么我该怎么做呢?
【问题讨论】:
-
“我似乎无法正常工作”是什么意思?你得到什么输出?