我想从函数中获取返回值,但我认为因为函数在类内部引起的问题。 这是类代码:
class language{
private $dbh;
function messanger($code){
switch ($code){
case 1: // Home Page is not configured
exit("<span class='sysError'>Query Error: </span><span class='sysMessage'>Please Set Home Page</span> ");
break;
}
}
function add($index){
$ins = $this->dbh->insert("INSERT INTO language (example) VALUES (:example)",Array(":example"=>$index));
($ins ? "" : exit(1));
}
public function show($transed = Array()){
(isset($_GET['lang']) ? $index = $_GET['lang'] : "");
(isset($_POST['lang']) ? $index = $_POST['lang'] : "");
if(isset($transed[$index]) && $transed[$index] != ""){
return $transed[$index];
}else{
return $transed['example'];
}
}
function take($index){
$out = $this->dbh->selectOne("SELECT * FROM language WHERE example = :example",Array(":example"=>$index));
($out ? $this->show($out) : $this->add($index));
}
public function __construct(){
global $connect;
global $docRoot;
global $startLang;
$this->dbh = new Queryer($connect);
}
}
所以我试着像这样打电话给这个班:
$lang = new language;
echo $lang->take("name");
echo $lang->take("last name");
在动作函数中命名为“take”调用函数名为“show”,并在函数显示中看到我有返回stateman,但echo无法获得此返回值,如果我将改变返回stateman with echo它的工作但我需要回报,为什么回归不起作用?