diff --git a/Koterov-php-training/methods_of_classes/index.php b/Koterov-php-training/methods_of_classes/index.php index c466344..dc06dc3 100644 --- a/Koterov-php-training/methods_of_classes/index.php +++ b/Koterov-php-training/methods_of_classes/index.php @@ -44,12 +44,12 @@ if (method_exists($point,'say')) { $greeting = new Greeting; -$greeting->x = 5; +// $greeting->x = 5; if (method_exists($greeting,'x')) { echo $greeting->x; } -$point->z = 5; +// $point->z = 5; echo '
'; print_r($point->listVariables()); @@ -63,4 +63,52 @@ echo ""; echo $rainbow->red; echo ""; echo $rainbow->unknown; -echo ""; \ No newline at end of file +echo ""; + +// require_once ('object.php'); + +// $objectConf = new Config; + +// $objectConf->title = 'Название сайта'; +// $objectConf->keywords = ['PHP', 'Phyton', 'Ruby', 'JavaScript' ]; +// $objectConf->per_page = 20; + +// echo ''; +// print_r( $objectConf ); +// echo ''; + +require_once ('settings.php'); + +$settings = new Settings; + +$settings->title = 'Название сайта'; +$settings->keywords = ['PHP', 'Phyton', 'Ruby', 'JavaScript' ]; +$settings->per_page = 20; + +echo ''; +print_r( $settings ); +echo ''; + +require_once ('static_greeting.php'); + +echo StaticGreeting::say('Kitty'); + +require_once ('page.php'); + +Page::render(); + +require_once ('static.php'); + +for ($objs = [], $i = 0; $i < 6; $i++) { + $objs[$i] = new Counter(); +} + +echo "Сейчас существует {$objs[0]->getCount()} объектов.
"; + +$objs[5] = null; + +echo"А теперь - {$objs[0]->getCount()} объекстов.
"; + +$objs = []; + +echo 'Под конец осталось - '. Counter::getCount() .' Объектов.
'; \ No newline at end of file diff --git a/Koterov-php-training/methods_of_classes/object.php b/Koterov-php-training/methods_of_classes/object.php new file mode 100644 index 0000000..87d860a --- /dev/null +++ b/Koterov-php-training/methods_of_classes/object.php @@ -0,0 +1,5 @@ +'; + + public static function footer() + { + return 'footer
'; + } + public static function header() + { + return 'header
'; + } + + public static function render() + { + echo self::header() . + self::$content . + self::footer(); + echo '
'; + } +} \ No newline at end of file diff --git a/Koterov-php-training/methods_of_classes/settings.php b/Koterov-php-training/methods_of_classes/settings.php new file mode 100644 index 0000000..873a5c3 --- /dev/null +++ b/Koterov-php-training/methods_of_classes/settings.php @@ -0,0 +1,23 @@ +properties)) { + return $this->properties[$key]; + } else { + return null; + } + } + + public function __set(string $key, $value): void + { + $this->properties[$key] = $value; + } + public function list(): array + { + return $this->properties; + } +} diff --git a/Koterov-php-training/methods_of_classes/static.php b/Koterov-php-training/methods_of_classes/static.php new file mode 100644 index 0000000..c515b59 --- /dev/null +++ b/Koterov-php-training/methods_of_classes/static.php @@ -0,0 +1,25 @@ +"; + } +} \ No newline at end of file diff --git a/cristmass-tree/index.php b/cristmass-tree/index.php index ce11aba..5b23d49 100644 --- a/cristmass-tree/index.php +++ b/cristmass-tree/index.php @@ -2,5 +2,5 @@ include_once ('tree.php'); -$cristmassTree = new Tree(50); +$cristmassTree = new Tree(25); $cristmassTree->drawTree();