Это файл index.php в корневой директории:PHP - Передача переменных в index.php
index.php
<?php
require_once 'engine.php';
require_once 'startController.php';
$engine = new Engine('start');
?>
<html>
<head>
<title>
</title>
</head>
</html>
В классе двигателей есть еще один объект
engine.php
class Engine
{
puublic $controller = null;
public function __construct($controller)
{
$controllerFile = $controller.'Controller';
$this->controller = new $controllerFile('Page');
}
}
и контроллер класса
startController.php
class startController
{
public function __construct($text)
{
$variable = 'Start'.$text; // output "StartPage" because of $text val.
}
}
Вопрос: как передать $variable
от startController
объекта index.php и дисплей betwen title
наценки?
Set ' $ variable' в свойство класса, добавьте метод getter tha t возвращает это свойство (если свойство не является общедоступным), вызовите этот метод в экземпляре класса startController. Готово. –