itmo-php-course/Koterov-php-training/methods_of_classes/index.php

137 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once 'greeting.php';
$object = new Greeting;
echo $object->say('PHP');
echo "</br></br>";
require_once 'point.php';
$point = new Point(3, 5);
// $point->__construct();
// $point->inner();
echo "</br>";
var_dump( $point->getX());
echo "</br>";
var_dump( $point->getY());
echo "</br></br>";
// $point->setX(5);
// $point->setY(7);
var_dump( $point->getX());
echo "</br>";
var_dump( $point->getY());
echo "</br></br>";
echo $point->distance;
echo '<pre>';
print_r($point);
echo '</pre>';
// echo $point->x;
// echo '</br>';
echo '<pre>';
print_r(get_class_methods($point));
echo '</pre>';
if (method_exists($point,'say')) {
echo $point->say('PHP');
}
$greeting = new Greeting;
// $greeting->x = 5;
if (method_exists($greeting,'x')) {
echo $greeting->x;
}
// $point->z = 5;
echo '<pre>';
print_r($point->listVariables());
echo '</pre>';
require_once ('rainbow.php');
$rainbow = new Rainbow;
echo $rainbow->yellow;
echo "</br>";
echo $rainbow->red;
echo "</br>";
echo $rainbow->unknown;
echo "</br>";
// require_once ('object.php');
// $objectConf = new Config;
// $objectConf->title = 'Название сайта';
// $objectConf->keywords = ['PHP', 'Phyton', 'Ruby', 'JavaScript' ];
// $objectConf->per_page = 20;
// echo '<pre>';
// print_r( $objectConf );
// echo '</pre>';
require_once ('settings.php');
$settings = new Settings;
$settings->title = 'Название сайта';
$settings->keywords = ['PHP', 'Phyton', 'Ruby', 'JavaScript' ];
$settings->per_page = 20;
echo '<pre>';
print_r( $settings );
echo '</pre>';
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()} объектов.<br/>";
$objs[5] = null;
echo"А теперь - {$objs[0]->getCount()} объекстов.<br/>";
$objs = [];
echo 'Под конец осталось - '. Counter::getCount() .' Объектов. <br/><br/>';
// require_once "minmax.php";
// $obj = new MinMax();
// echo $obj->min(43, 18, 5, 61, 23, 10, 56, 36);
// echo '<br/>';
// echo $obj->max(43, 18, 5, 61, 23);
// echo '<br/><br/>';
require_once "minmax_alter.php";
$obj = new MinMaxAlt();
echo $obj->min(43, 18, 5, 61, 23, 10, 56, 36);
echo '<br/>';
echo $obj->max(43, 18, 5, 61, 23);
echo '<br/><br/>';
require_once "minmax_static.php";
echo 'Вызов статического метода __callStatic() <br/><br/>';
echo MinMaxStat::min(43, 18, 5, 61, 23, 10, 56, 36);
echo '<br/>';
echo MinMaxStat::max(43, 18, 5, 61, 23);
echo '<br/><br/>';