将两个 类 函数调用到一个排序输出

calling two classes functions to one sorted output

我正在浏览 index.php 文件,我的代码是这样的:

index.php =

require("template.php"); // the file with the template of the site

$title="Home";
$phead='';
$html->htmlhead();

$htmlside="";
$html->htmlside();

require("file2.php"); // a file with class $queans and function question()
$htmlbody = $queans->questions();
$html->htmlbody($htmlbody);

$htmlfoot="";
$html->htmlfoot();

template.php = 包含 class $html 以及我在上一个文件中编写的所有功能。以及带有 htmlbody 函数的特定配置文件:

//all the class plugin
//in this specific function i wrote
$html->htmlbody($htmlbody){
   echo '<div id="s">'.$htmlbody.'</div>';
}

file2.php =

$queans = new ques;
class ques{
    public function questions(){
        echo 'test';
    }
}

最后它显示 $queans->questions() 的输出在 function questions() 的输出之前,输出如下:

test
<div id="s">
</div>

在您的 file2.php 中,您必须 return 'test' 而不是回应它。