oop koterov-simodyanov
This commit is contained in:
parent
ef67839659
commit
411e87503f
11
Koterov-php-training/arrays/index.php
Normal file
11
Koterov-php-training/arrays/index.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$arr = [
|
||||
0 => "Нулевой элемент",
|
||||
"surname" => "Гейтс",
|
||||
"name" => "Билл",
|
||||
];
|
||||
echo $arr['surname'];
|
||||
$arr[1] = "Первый элемент";
|
||||
$arr["name"] = "Вильям";
|
||||
|
||||
echo $arr['name'];
|
10
Koterov-php-training/classes_and_metods/DateTime/index.php
Normal file
10
Koterov-php-training/classes_and_metods/DateTime/index.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$date = new DateTime();
|
||||
echo $date->format('d-m-Y H:i:s');
|
||||
echo "<br/>";
|
||||
echo gettype($date);
|
||||
echo "<br/>";
|
||||
echo get_class( $date );
|
||||
echo "<br/>";
|
||||
echo $date::class;
|
111
Koterov-php-training/classes_and_metods/PointClass/index.php
Normal file
111
Koterov-php-training/classes_and_metods/PointClass/index.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
require 'point.php';
|
||||
|
||||
$point = new Point;
|
||||
// var_dump($point->x);
|
||||
|
||||
$point->x = 5;
|
||||
$point->y = 3.2;
|
||||
|
||||
echo '<pre>';
|
||||
print_r($point);
|
||||
echo '</pre>';
|
||||
echo "<br/>";
|
||||
|
||||
|
||||
|
||||
echo $point->x;
|
||||
echo "<br/>";
|
||||
echo $point->y;
|
||||
echo "<br/>";
|
||||
echo gettype($point);
|
||||
echo "<br/>";
|
||||
echo get_class($point);
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
echo ($point ->x ** 2 + $point ->y ** 2) ** 0.5 . ' - Такое вот вычисление';
|
||||
echo "<br/>";
|
||||
// Уничтожение объекта
|
||||
// unset($point);
|
||||
// echo $point->x;
|
||||
|
||||
require_once('private_point.php');
|
||||
|
||||
$prpoint = new PrivatePoint;
|
||||
|
||||
$prpoint->x = 3;
|
||||
|
||||
|
||||
echo $prpoint->x;
|
||||
echo "<br/>";
|
||||
|
||||
echo gettype($prpoint);
|
||||
echo "<br/>";
|
||||
echo get_class($prpoint);
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
echo ($prpoint ->x ** 2 + $point ->y ** 2) ** 0.5 . ' - Такое вот вычисление';
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
|
||||
require_once('readonly.php');
|
||||
|
||||
$obj = new Greating;
|
||||
echo $obj->setter();
|
||||
echo "<br/>";
|
||||
echo "Hello $obj->hello";
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
|
||||
require_once('readonly_construct.php');
|
||||
|
||||
$object = new GreatingConst();
|
||||
echo "Hello construct $object->hello";
|
||||
echo "<br/>";
|
||||
echo gettype($object);
|
||||
echo '<pre>';
|
||||
print_r($object);
|
||||
echo '</pre>';
|
||||
echo "<br/>";
|
||||
|
||||
require_once("my_static.php");
|
||||
echo "Статическая переменная: ". MyStatic::$staticvar;
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
|
||||
// $first = $second = 1;
|
||||
// $first = 3;
|
||||
// echo $second;
|
||||
// echo "<br/>";
|
||||
// echo "<br/>";
|
||||
// echo $first;
|
||||
// echo "<br/>";
|
||||
// echo "<br/>";
|
||||
|
||||
$first = new Point;
|
||||
$first->x = 3;
|
||||
$first->y = 3;
|
||||
|
||||
$second = $first;
|
||||
|
||||
$second->x = 5;
|
||||
$second->y = 5;
|
||||
echo "x: {$first->x}, y: {$first->y}";
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
|
||||
$firstvar = 5;
|
||||
$secondvar = &$firstvar;
|
||||
$secondvar = 1;
|
||||
echo $firstvar;
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
|
||||
$secondclone = clone $first;
|
||||
$secondclone->x = 9;
|
||||
$secondclone->y = 9;
|
||||
echo "Объект first до клонирования - x: {$first->x}, y: {$first->y}";
|
||||
echo "<br/>";
|
||||
echo "<br/>";
|
||||
echo "Объект first после клонирования - x: {$secondclone->x}, y: {$secondclone->y}";
|
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class MyStatic
|
||||
{
|
||||
public static $staticvar = 100;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Point
|
||||
{
|
||||
public int|float $x;
|
||||
public int|float $y;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class PrivatePoint {
|
||||
public $x;
|
||||
private $y = 3;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class Greating
|
||||
{
|
||||
public readonly string $hello;
|
||||
public function setter() {
|
||||
$this->hello = "PHP";
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class GreatingConst
|
||||
{
|
||||
public readonly string $hello;
|
||||
public function __construct() {
|
||||
$this->hello = "PHP";
|
||||
}
|
||||
}
|
6
Koterov-php-training/operator_angle_brackets/index.php
Normal file
6
Koterov-php-training/operator_angle_brackets/index.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$name = "Имя пользователя";
|
||||
$str = <<<'HTML_END'
|
||||
Переменные PHP не будут мнтерполироваться: $name
|
||||
HTML_END;
|
||||
echo $str;
|
@ -29,7 +29,7 @@ function render($tpl, $data)
|
||||
return $content;
|
||||
}
|
||||
|
||||
$value = ['box' => $box, 'title' => "God save the King!", 'body' => "Happy New Year!", 'auth' => true];
|
||||
$value = ['box' => $box, 'title' => "God save the King!", 'body' => "Happy New Year!", 'auth' => false];
|
||||
$portial = render('tpl_layout.php', $value);
|
||||
|
||||
echo $portial;
|
BIN
engine/upload/Bolshoi_sekret_dlya_malenkoi.mp3
Normal file
BIN
engine/upload/Bolshoi_sekret_dlya_malenkoi.mp3
Normal file
Binary file not shown.
BIN
engine/upload/CHesnya_chernogo_kota.mp3
Normal file
BIN
engine/upload/CHesnya_chernogo_kota.mp3
Normal file
Binary file not shown.
BIN
engine/upload/Oblaka_-.mp3
Normal file
BIN
engine/upload/Oblaka_-.mp3
Normal file
Binary file not shown.
BIN
engine/upload/Корпорация Монстров — Катастрофа сознания.mp3
Normal file
BIN
engine/upload/Корпорация Монстров — Катастрофа сознания.mp3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user