多次运行相同的方法
问题描述:
<?php
class article{
private $row;
public function __construct(){
require_once('connection.php');
mysql_select_db($db, $test);
$query = "SELECT * FROM articles WHERE path = $_SESSION['path']";
$result = mysql_query($query, $test) or die(mysql_error());
$this->row = mysql_fetch_array($result);
}
public function process($field) {
if($field == 'tool'){
echo $this->row['path'];
}
else if($field == 'test'){
echo $this->row['title'];
}
}
}
$obj = new article();
$obj->process('tool');
$obj = new article();
$obj1->process('test');
?>
如何在这种情况下运行两次流程方法?它只运行一次,执行停止。
How to run the process method twice in this scenario? It just run once and execution stops.
答
row ;
public function __construct(){
require_once(' connection .PHP'跨度>);
mysql_select_db(
row; public function __construct(){ require_once('connection.php'); mysql_select_db(
db,
test);
test);