randomClass.php
class randomClass
{
private $perPage = 8;
private $startPage = 0;
function perPage($perPage)
{
$this->db->perPage = $perPage;
}
function startPage($startPage)
{
$this->db->startPage = $startPage;
}
public function usingBothVariables()
{
$sth = $this->db->prepare("SELECT rndm FROM table LIMIT ?, ?");
$sth->execute(array($this->startPage, $this->PerPage));
$row = $sth->fetchAll();
return $row;
}
{
index.php
if($randomVariable < 1)
use startPage function here = 0;
else
use startPage function here = $randomVariable * use $perPage function here;
答案 0 :(得分:1)
在randomClass中:
public function getPerPage(){
return $this->perPage;
}
public function getStartPage(){
return $this->startPage;
}
现在在index.php中,您可以调用这些方法来获取yuor变量。