我有一个基类
class View {
private $inner;
public function setInner($inner) {
$this->inner = $inner;
}
public function template($inner) {
$this->setInner($inner);
echo <<<HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
WebCrawler
</title>
<meta name="description" content="The URL Link Finder">
<meta name="author" content="JohnW">
<link rel="stylesheet" href="css/styles.css?v=1.0">
</head>
<body>
<!--Inner html-->
{$this->inner}
<!-- Inner html-->.....
我有一个扩展该类的子类
class NewUserView extends View {
private $inner = 'Please enter your details here';
//for new users to sign up
public function show() {
$this->body = <<<HTML
<body>
<!--Inner html-->
{$this->inner}
<!-- Inner html-->
<br/>
<form action="index.php" method="post">
Name: <input t....
因此,当我创建 NewUserView 的实例时,我希望能够通过以下命令更改 $inner 字符串。
$view = new NewUserView;
$view->setInner($this->sessionSignUp($value));
$view->show();
然而,原始的 $inner, 'please set your details' 仍然显示在我的视图中,它应该是从 sessionSignUp 函数传入的字符串。谁能帮我理解我做错了什么。
谢谢