找出这串代码的错误并给出正确答案<?php include_once "page.php"; class FirstPage extends Page { public function __construct($title) { parent::__construct($title); } public function DisplayContent() { ?> <form action="vote.php" method="post"> <table> <tr> <td>用户名:</td> <td><input type="text" name="username"></td> </tr> <tr> <td colspan="2"><button type="submit">下一步</button></td> </tr> </table> </form> <?php } } $page=new FirstPage("输入用户名"); $page->Display(); ?>
时间: 2024-02-14 20:08:46 浏览: 78
simple_page.rar_page_struts 分页
在代码的最后一行,`$page->Display()`应该改为`$page->DisplayContent()`,因为在FirstPage类中没有名为Display()的方法,只有DisplayContent()方法。修改后的代码如下:
```php
<?php
include_once "page.php";
class FirstPage extends Page {
public function __construct($title) {
parent::__construct($title);
}
public function DisplayContent() {
?>
<form action="vote.php" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td colspan="2"><button type="submit">下一步</button></td>
</tr>
</table>
</form>
<?php
}
}
$page = new FirstPage("输入用户名");
$page->DisplayContent();
?>
```
阅读全文