From 8b99b51ec8f4046477410d8caa8b360ab45bea9f Mon Sep 17 00:00:00 2001 From: Igor Simdyanov Date: Fri, 27 May 2022 21:28:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BB=D0=B0=D0=B2=D0=B0=2036:=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D1=82=D1=80=D0=B0=D0=BD=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=BE=20=D0=B8=D0=BC=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- namespace/PHP8/page.php | 18 ++++++++++++++++ namespace/PHP8/seo.php | 25 ++++++++++++++++++++++ namespace/PHP8/tag.php | 11 ++++++++++ namespace/absolute.php | 16 +++++++++++++++ namespace/anonim.php | 8 ++++++++ namespace/autoload.php | 8 ++++++++ namespace/namespace.php | 22 ++++++++++++++++++++ namespace/namespace_const.php | 4 ++++ namespace/namespace_fail.php | 32 +++++++++++++++++++++++++++++ namespace/namespace_key.php | 12 +++++++++++ namespace/namespace_use.php | 6 ++++++ namespace/namespaces.php | 26 +++++++++++++++++++++++ namespace/namespaces_alt.php | 29 ++++++++++++++++++++++++++ namespace/namespaces_alt_use.php | 6 ++++++ namespace/relative.php | 6 ++++++ namespace/spl_autoload_register.php | 5 +++++ namespace/use.php | 10 +++++++++ namespace/wrong.php | 7 +++++++ 18 files changed, 251 insertions(+) create mode 100644 namespace/PHP8/page.php create mode 100644 namespace/PHP8/seo.php create mode 100644 namespace/PHP8/tag.php create mode 100644 namespace/absolute.php create mode 100644 namespace/anonim.php create mode 100644 namespace/autoload.php create mode 100644 namespace/namespace.php create mode 100644 namespace/namespace_const.php create mode 100644 namespace/namespace_fail.php create mode 100644 namespace/namespace_key.php create mode 100644 namespace/namespace_use.php create mode 100644 namespace/namespaces.php create mode 100644 namespace/namespaces_alt.php create mode 100644 namespace/namespaces_alt_use.php create mode 100644 namespace/relative.php create mode 100644 namespace/spl_autoload_register.php create mode 100644 namespace/use.php create mode 100644 namespace/wrong.php diff --git a/namespace/PHP8/page.php b/namespace/PHP8/page.php new file mode 100644 index 0000000..a7113c5 --- /dev/null +++ b/namespace/PHP8/page.php @@ -0,0 +1,18 @@ +title = $title; + $this->content = $content; + } +} diff --git a/namespace/PHP8/seo.php b/namespace/PHP8/seo.php new file mode 100644 index 0000000..a2ac6c5 --- /dev/null +++ b/namespace/PHP8/seo.php @@ -0,0 +1,25 @@ +'; + } + public function description() + { + // $query = 'SELECT description FROM seo WHERE id = :id LIMIT 1' + echo 'Seo::description
'; + } + public function ogs() + { + // $query = 'SELECT ogs FROM seo WHERE id = :id LIMIT 1' + echo 'Seo::ogs
'; + } +} diff --git a/namespace/PHP8/tag.php b/namespace/PHP8/tag.php new file mode 100644 index 0000000..faedb00 --- /dev/null +++ b/namespace/PHP8/tag.php @@ -0,0 +1,11 @@ +'; + } +} diff --git a/namespace/absolute.php b/namespace/absolute.php new file mode 100644 index 0000000..37f195c --- /dev/null +++ b/namespace/absolute.php @@ -0,0 +1,16 @@ +'; +// Это стандартная функция strlen() +echo \strlen('Hello world!').'
'; diff --git a/namespace/anonim.php b/namespace/anonim.php new file mode 100644 index 0000000..2391616 --- /dev/null +++ b/namespace/anonim.php @@ -0,0 +1,8 @@ +tags(); diff --git a/namespace/autoload.php b/namespace/autoload.php new file mode 100644 index 0000000..e148cbe --- /dev/null +++ b/namespace/autoload.php @@ -0,0 +1,8 @@ +tags(); diff --git a/namespace/namespace.php b/namespace/namespace.php new file mode 100644 index 0000000..a392f74 --- /dev/null +++ b/namespace/namespace.php @@ -0,0 +1,22 @@ +'; + print_r($obj); + echo ''; +} + +class Page +{ + protected $title; + protected $content; + public function __construct(string $title = '', string $content = '') + { + $this->title = $title; + $this->content = $content; + } +} diff --git a/namespace/namespace_const.php b/namespace/namespace_const.php new file mode 100644 index 0000000..6be6417 --- /dev/null +++ b/namespace/namespace_const.php @@ -0,0 +1,4 @@ + + + + Пространство имен + + + +'; + print_r($obj); + echo ''; +} + +class Page +{ + protected $title; + protected $content; + public function __construct(string $title = '', string $content = '') + { + $this->title = $title; + $this->content = $content; + } +} +?> + + diff --git a/namespace/namespace_key.php b/namespace/namespace_key.php new file mode 100644 index 0000000..39fbea2 --- /dev/null +++ b/namespace/namespace_key.php @@ -0,0 +1,12 @@ +'; +echo strlen('Hello, world!') . '
'; +echo namespace\strlen('Hello, world!') . '
'; diff --git a/namespace/namespace_use.php b/namespace/namespace_use.php new file mode 100644 index 0000000..f17e3c4 --- /dev/null +++ b/namespace/namespace_use.php @@ -0,0 +1,6 @@ +'; +$page = new PHP8\Page('Контакты', 'Содержимое страницы'); +PHP8\debug($page); diff --git a/namespace/namespaces.php b/namespace/namespaces.php new file mode 100644 index 0000000..ad73cc3 --- /dev/null +++ b/namespace/namespaces.php @@ -0,0 +1,26 @@ +'; + print_r($obj); + echo ''; +} + +namespace PHP8\classes; + +class Page +{ + protected $title; + protected $content; + public function __construct(string $title = '', string $content = '') + { + $this->title = $title; + $this->content = $content; + } +} diff --git a/namespace/namespaces_alt.php b/namespace/namespaces_alt.php new file mode 100644 index 0000000..3985e2b --- /dev/null +++ b/namespace/namespaces_alt.php @@ -0,0 +1,29 @@ +'; + print_r($obj); + echo ''; + } +} + +namespace PHP8\classes +{ + class Page + { + protected $title; + protected $content; + public function __construct(string $title = '', string $content = '') + { + $this->title = $title; + $this->content = $content; + } + } +} diff --git a/namespace/namespaces_alt_use.php b/namespace/namespaces_alt_use.php new file mode 100644 index 0000000..78e3a30 --- /dev/null +++ b/namespace/namespaces_alt_use.php @@ -0,0 +1,6 @@ +'; +$page = new PHP8\classes\Page('Контакты', 'Содержимое страницы'); +PHP8\functions\debug($page); diff --git a/namespace/relative.php b/namespace/relative.php new file mode 100644 index 0000000..9f67370 --- /dev/null +++ b/namespace/relative.php @@ -0,0 +1,6 @@ +tags(); // Tag::tags diff --git a/namespace/use.php b/namespace/use.php new file mode 100644 index 0000000..fa54afa --- /dev/null +++ b/namespace/use.php @@ -0,0 +1,10 @@ +'; +$page = new Page('Контакты', 'Содержимое страницы'); +functions\debug($page); diff --git a/namespace/wrong.php b/namespace/wrong.php new file mode 100644 index 0000000..6c23474 --- /dev/null +++ b/namespace/wrong.php @@ -0,0 +1,7 @@ +tags(); // Tag::tags