- Edited
Fatal error: Uncaught Error: Class "bob\html\page\Page" not found in /var/www/html/PHP-and-MySQL-Web-Development/Chapter06/importing-and-aliasing-namespace-pag-198/index.php:4 Stack trace: #0 {main} thrown in /var/www/html/PHP-and-MySQL-Web-Development/Chapter06/importing-and-aliasing-namespace-pag-198/index.php on line 4
index.php
<?php
include "Html.php";
use bob\html\page as www;
$table = new www\Page();
$table->title = "My table";
$table->numRows = 5;
?>
<html>
<body>
<?php $table->message(); ?>
</body>
</html>
Html.php
<?php
namespace Html;
class Page {
public $title = "";
public $numRows = 0;
public function message() {
echo "<p>Table '{$this->title}' has {$this->numRows} rows.</p>";
}
}
class Row {
public $numCells = 0;
public function message() {
echo "<p>The row has {$this->numCells} cells.</p>";
}
}
?>