diff --git a/engine/mvc.php b/engine/mvc.php new file mode 100644 index 0000000..b2ff9f6 --- /dev/null +++ b/engine/mvc.php @@ -0,0 +1,27 @@ + 'Main Page', + 'h3' => 'С новым годом!']; + } +} +class MainController { + public function index() + { + $model = new MainModel(); + $view = new MainView(); + $result = $model->getData(); + $view->render($result, 'main.tpl'); + } +} +class MainView { + public function render($data, $tmpl) + { + var_dump($data); + } +} + +$controll = new MainController(); +$controll->index(); \ No newline at end of file diff --git a/engine/oop.php b/engine/oop.php new file mode 100644 index 0000000..8c0cd37 --- /dev/null +++ b/engine/oop.php @@ -0,0 +1,92 @@ +radius = $r; + $this->hight = $h; + } +} + +class SectionTreeChild extends SectionTree { + public $wight = 50; + public function __construct() + { + parent::__construct(233, 23); + } + + public function getRadius() + { + return $this->radius; + } + +} + +$objChild = new SectionTreeChild(255, 22); + +var_dump($objChild->getRadius()); + +// var_dump(SectionTree::$radius); + +class ChristmasTree +{ + private $sectionBox = []; + protected $color = 'red'; + + public function getColor() + { + return $this->color; + } + + public function addSection($section) + { + array_push($this->sectionBox, $section); + } + + public function debug() + { + var_dump($this->sectionBox); + } + +} +// () - вызов конструктора, оператор call + +$s_1 = new SectionTree(12, 2); +$s_2 = new SectionTree(3, 5); + +$tree = new ChristmasTree(); +$tree->addSection($s_1); +$tree->addSection($s_2); +// $tree->addSection('ddd'); +// $tree->addSection(283746); +$tree->debug(); + + +// var_dump($obj->getColor()); + +class DB { + const SQL_SELECT_USER = 'select, id, name, login from user, where id = %'; + static private $_instanse; + private function __construct() + { + + } + + static public function getInstanse() + { + if (!self::$_instanse) { + self::$_instanse = new self(); + } + return self::$_instanse; + } + static public function runSQL() + { + var_dump(self::SQL_SELECT_USER); + } +} + +$objInst = DB::getInstanse(); +DB::runSQL(); +var_dump($objInst); \ No newline at end of file