com web/php: Syntax highlighting for other languages: releases/8_0_x_pt_BR.php releases/8_0_x _ru.php
| From: | Sara Golemon | Date: | Wed, 25 Nov 2020 20:28:13 +0000 |
| Subject: | com web/php: Syntax highlighting for other languages: releases/8_0_x_pt_BR.php releases/8_0_x _ru.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-28876@lists.php.net to get a copy of this message | ||
Commit: 992fefd0a25f3b39332ff6db748197bee30ba20b
Author: Ruslan <naruzl@yandex.ru> Sat, 21 Nov 2020 02:17:24 +0300
Committer: Sara Golemon <pollita@php.net> Wed, 25 Nov 2020 20:28:13 +0000
Parents: 6877a6e5dda2ab67854290943e2734c91f8431dc
Branches: master
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=992fefd0a25f3b39332ff6db748197bee30ba20b
Log:
Syntax highlighting for other languages
Changed paths:
M releases/8_0_x_pt_BR.php
M releases/8_0_x_ru.php
diff --git a/releases/8_0_x_pt_BR.php b/releases/8_0_x_pt_BR.php index 33cca0c24..abdf76637 100644 --- a/releases/8_0_x_pt_BR.php +++ b/releases/8_0_x_pt_BR.php @@ -53,14 +53,18 @@ site_header("PHP 8.0.0 Release Announcement", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, double_encode: false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, double_encode: false);' + );?> </div> </div> </div> @@ -81,20 +85,24 @@ site_header("PHP 8.0.0 Release Announcement", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>/** + <?php highlight_php_trimmed( + '/** * @Route("/api/posts/{id}", methods={"GET", "HEAD"}) */ -classUser -{</pre> +class User +{' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] + <?php highlight_php_trimmed( + '#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] class User -{</pre> +{' + );?> </div> </div> </div> @@ -112,34 +120,38 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Point { - public float $x; - public float $y; - public float $z; + <?php highlight_php_trimmed( + 'class Point { + public float $x; + public float $y; + public float $z; - public function __construct( - float $x = 0.0, - float $y = 0.0, - float $z = 0.0, - ) { - $this->x = $x; - $this->y = $y; - $this->z = $z; - } -}</pre> + public function __construct( + float $x = 0.0, + float $y = 0.0, + float $z = 0.0, + ) { + $this->x = $x; + $this->y = $y; + $this->z = $z; + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Point { - public function __construct( - public float $x = 0.0, - public float $y = 0.0, - public float $z = 0.0, - ) {} -}</pre> + <?php highlight_php_trimmed( + 'class Point { + public function __construct( + public float $x = 0.0, + public float $y = 0.0, + public float $z = 0.0, + ) {} +}' + );?> </div> </div> </div> @@ -157,32 +169,36 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Number { - /** @var int|float */ - private $number; + <?php highlight_php_trimmed( + 'class Number { + /** @var int|float */ + private $number; - /** - * @param float|int $number - */ - public function __construct($number) { - $this->number = $number; - } + /** + * @param float|int $number + */ + public function __construct($number) { + $this->number = $number; + } } -new Number('NaN'); // Ok</pre> +new Number(\'NaN\'); // Ok' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Number { - public function __construct( - private int|float $number - ) {} + <?php highlight_php_trimmed( + 'class Number { + public function __construct( + private int|float $number + ) {} } -new Number('NaN'); // TypeError</pre> +new Number(\'NaN\'); // TypeError' + );?> </div> </div> </div> @@ -201,27 +217,31 @@ new Number('NaN'); // TypeError</pre> <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>switch (8.0) { - case '8.0': - $result = "Oh no!"; - break; - case 8.0: - $result = "This is what I expected"; - break; + <?php highlight_php_trimmed( + 'switch (8.0) { + case \'8.0\': + $result = "Oh no!"; + break; + case 8.0: + $result = "This is what I expected"; + break; } echo $result; -//> Oh no!</pre> +//> Oh no!' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>echo match (8.0) { - '8.0' => "Oh no!", - 8.0 => "This is what I expected", + <?php highlight_php_trimmed( + 'echo match (8.0) { + \'8.0\' => "Oh no!", + 8.0 => "This is what I expected", }; -//> This is what I expected</pre> +//> This is what I expected' + );?> </div> </div> </div> @@ -245,26 +265,30 @@ echo $result; <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>$country = null; + <?php highlight_php_trimmed( + '$country = null; if ($session !== null) { - $user = $session->user; - - if ($user !== null) { - $address = $user->getAddress(); + $user = $session->user; - if ($address !== null) { - $country = $address->country; - } - } -}</pre> + if ($user !== null) { + $address = $user->getAddress(); + + if ($address !== null) { + $country = $address->country; + } + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>$country = $session?->user?->getAddress()?->country;</pre> + <?php highlight_php_trimmed( + '$country = $session?->user?->getAddress()?->country;' + );?> </div> </div> </div> @@ -284,14 +308,18 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // true</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // true' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // false</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // false' + );?> </div> </div> </div> @@ -310,18 +338,22 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>strlen([]); // Warning: strlen() expects parameter 1 to be string, array given + <?php highlight_php_trimmed( + 'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given -array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0</pre> +array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given + <?php highlight_php_trimmed( + 'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given -array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0</pre> +array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0' + );?> </div> </div> </div> diff --git a/releases/8_0_x_ru.php b/releases/8_0_x_ru.php index ed860a7bc..11a85708e 100644 --- a/releases/8_0_x_ru.php +++ b/releases/8_0_x_ru.php @@ -52,14 +52,18 @@ site_header("PHP 8.0.0, релиз", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, double_encode: false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, double_encode: false);' + );?> </div> </div> </div> @@ -80,20 +84,24 @@ site_header("PHP 8.0.0, релиз", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>/** + <?php highlight_php_trimmed( + '/** * @Route("/api/posts/{id}", methods={"GET", "HEAD"}) */ -classUser -{</pre> +class User +{' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] + <?php highlight_php_trimmed( + '#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] class User -{</pre> +{' + );?> </div> </div> </div> @@ -111,34 +119,38 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Point { - public float $x; - public float $y; - public float $z; + <?php highlight_php_trimmed( + 'class Point { + public float $x; + public float $y; + public float $z; - public function __construct( - float $x = 0.0, - float $y = 0.0, - float $z = 0.0, - ) { - $this->x = $x; - $this->y = $y; - $this->z = $z; - } -}</pre> + public function __construct( + float $x = 0.0, + float $y = 0.0, + float $z = 0.0, + ) { + $this->x = $x; + $this->y = $y; + $this->z = $z; + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Point { - public function __construct( - public float $x = 0.0, - public float $y = 0.0, - public float $z = 0.0, - ) {} -}</pre> + <?php highlight_php_trimmed( + 'class Point { + public function __construct( + public float $x = 0.0, + public float $y = 0.0, + public float $z = 0.0, + ) {} +}' + );?> </div> </div> </div> @@ -156,32 +168,36 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Number { - /** @var int|float */ - private $number; + <?php highlight_php_trimmed( + 'class Number { + /** @var int|float */ + private $number; - /** - * @param float|int $number - */ - public function __construct($number) { - $this->number = $number; - } + /** + * @param float|int $number + */ + public function __construct($number) { + $this->number = $number; + } } -new Number('NaN'); // Нет ошибки</pre> +new Number(\'NaN\'); // Нет ошибки' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Number { - public function __construct( - private int|float $number - ) {} + <?php highlight_php_trimmed( + 'class Number { + public function __construct( + private int|float $number + ) {} } -new Number('NaN'); // TypeError</pre> +new Number(\'NaN\'); // TypeError' + );?> </div> </div> </div> @@ -200,27 +216,31 @@ new Number('NaN'); // TypeError</pre> <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>switch (8.0) { - case '8.0': - $result = "О нет!"; - break; - case 8.0: - $result = "То, что я и ожидал"; - break; + <?php highlight_php_trimmed( + 'switch (8.0) { + case \'8.0\': + $result = "О нет!"; + break; + case 8.0: + $result = "То, что я и ожидал"; + break; } echo $result; -//> О нет!</pre> +//> О нет!' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>echo match (8.0) { - '8.0' => "О нет!", - 8.0 => "То, что я и ожидал", + <?php highlight_php_trimmed( + 'echo match (8.0) { + \'8.0\' => "О нет!", + 8.0 => "То, что я и ожидал", }; -//> То, что я и ожидал</pre> +//> То, что я и ожидал' + );?> </div> </div> </div> @@ -243,31 +263,35 @@ echo $result; <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>$country = null; + <?php highlight_php_trimmed( + '$country = null; if ($session !== null) { - $user = $session->user; - - if ($user !== null) { - $address = $user->getAddress(); + $user = $session->user; - if ($address !== null) { - $country = $address->country; - } - } -}</pre> + if ($user !== null) { + $address = $user->getAddress(); + + if ($address !== null) { + $country = $address->country; + } + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>$country = $session?->user?->getAddress()?->country;</pre> + <?php highlight_php_trimmed( + '$country = $session?->user?->getAddress()?->country;' + );?> </div> </div> </div> <div class="php8-compare__content"> - Вместо проверки на null вы можете использовать последовательность вызовов с новым оператором Nullsafe. Когда + <p>Вместо проверки на null вы можете использовать последовательность вызовов с новым оператором Nullsafe. Когда один из элементов в последовательности возвращает null, выполнение прерывается и вся последовательность возвращает null.</p> </div> @@ -282,14 +306,18 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // true</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // true' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // false</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // false' + );?> </div> </div> </div> @@ -308,18 +336,22 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>strlen([]); // Warning: strlen() expects parameter 1 to be string, array given + <?php highlight_php_trimmed( + 'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given -array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0</pre> +array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given + <?php highlight_php_trimmed( + 'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given -array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0</pre> +array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0' + );?> </div> </div> </div>
diff --git a/releases/8_0_x_pt_BR.php b/releases/8_0_x_pt_BR.php index 33cca0c24..abdf76637 100644 --- a/releases/8_0_x_pt_BR.php +++ b/releases/8_0_x_pt_BR.php @@ -53,14 +53,18 @@ site_header("PHP 8.0.0 Release Announcement", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, double_encode: false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, double_encode: false);' + );?> </div> </div> </div> @@ -81,20 +85,24 @@ site_header("PHP 8.0.0 Release Announcement", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>/** + <?php highlight_php_trimmed( + '/** * @Route("/api/posts/{id}", methods={"GET", "HEAD"}) */ -classUser -{</pre> +class User +{' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] + <?php highlight_php_trimmed( + '#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] class User -{</pre> +{' + );?> </div> </div> </div> @@ -112,34 +120,38 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Point { - public float $x; - public float $y; - public float $z; + <?php highlight_php_trimmed( + 'class Point { + public float $x; + public float $y; + public float $z; - public function __construct( - float $x = 0.0, - float $y = 0.0, - float $z = 0.0, - ) { - $this->x = $x; - $this->y = $y; - $this->z = $z; - } -}</pre> + public function __construct( + float $x = 0.0, + float $y = 0.0, + float $z = 0.0, + ) { + $this->x = $x; + $this->y = $y; + $this->z = $z; + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Point { - public function __construct( - public float $x = 0.0, - public float $y = 0.0, - public float $z = 0.0, - ) {} -}</pre> + <?php highlight_php_trimmed( + 'class Point { + public function __construct( + public float $x = 0.0, + public float $y = 0.0, + public float $z = 0.0, + ) {} +}' + );?> </div> </div> </div> @@ -157,32 +169,36 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Number { - /** @var int|float */ - private $number; + <?php highlight_php_trimmed( + 'class Number { + /** @var int|float */ + private $number; - /** - * @param float|int $number - */ - public function __construct($number) { - $this->number = $number; - } + /** + * @param float|int $number + */ + public function __construct($number) { + $this->number = $number; + } } -new Number('NaN'); // Ok</pre> +new Number(\'NaN\'); // Ok' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Number { - public function __construct( - private int|float $number - ) {} + <?php highlight_php_trimmed( + 'class Number { + public function __construct( + private int|float $number + ) {} } -new Number('NaN'); // TypeError</pre> +new Number(\'NaN\'); // TypeError' + );?> </div> </div> </div> @@ -201,27 +217,31 @@ new Number('NaN'); // TypeError</pre> <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>switch (8.0) { - case '8.0': - $result = "Oh no!"; - break; - case 8.0: - $result = "This is what I expected"; - break; + <?php highlight_php_trimmed( + 'switch (8.0) { + case \'8.0\': + $result = "Oh no!"; + break; + case 8.0: + $result = "This is what I expected"; + break; } echo $result; -//> Oh no!</pre> +//> Oh no!' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>echo match (8.0) { - '8.0' => "Oh no!", - 8.0 => "This is what I expected", + <?php highlight_php_trimmed( + 'echo match (8.0) { + \'8.0\' => "Oh no!", + 8.0 => "This is what I expected", }; -//> This is what I expected</pre> +//> This is what I expected' + );?> </div> </div> </div> @@ -245,26 +265,30 @@ echo $result; <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>$country = null; + <?php highlight_php_trimmed( + '$country = null; if ($session !== null) { - $user = $session->user; - - if ($user !== null) { - $address = $user->getAddress(); + $user = $session->user; - if ($address !== null) { - $country = $address->country; - } - } -}</pre> + if ($user !== null) { + $address = $user->getAddress(); + + if ($address !== null) { + $country = $address->country; + } + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>$country = $session?->user?->getAddress()?->country;</pre> + <?php highlight_php_trimmed( + '$country = $session?->user?->getAddress()?->country;' + );?> </div> </div> </div> @@ -284,14 +308,18 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // true</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // true' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // false</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // false' + );?> </div> </div> </div> @@ -310,18 +338,22 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>strlen([]); // Warning: strlen() expects parameter 1 to be string, array given + <?php highlight_php_trimmed( + 'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given -array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0</pre> +array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given + <?php highlight_php_trimmed( + 'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given -array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0</pre> +array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0' + );?> </div> </div> </div> diff --git a/releases/8_0_x_ru.php b/releases/8_0_x_ru.php index ed860a7bc..11a85708e 100644 --- a/releases/8_0_x_ru.php +++ b/releases/8_0_x_ru.php @@ -52,14 +52,18 @@ site_header("PHP 8.0.0, релиз", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, \'UTF-8\', false);' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>htmlspecialchars($string, double_encode: false);</pre> + <?php highlight_php_trimmed( + 'htmlspecialchars($string, double_encode: false);' + );?> </div> </div> </div> @@ -80,20 +84,24 @@ site_header("PHP 8.0.0, релиз", array( <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>/** + <?php highlight_php_trimmed( + '/** * @Route("/api/posts/{id}", methods={"GET", "HEAD"}) */ -classUser -{</pre> +class User +{' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] + <?php highlight_php_trimmed( + '#[Route("/api/posts/{id}", methods: ["GET", "HEAD"])] class User -{</pre> +{' + );?> </div> </div> </div> @@ -111,34 +119,38 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Point { - public float $x; - public float $y; - public float $z; + <?php highlight_php_trimmed( + 'class Point { + public float $x; + public float $y; + public float $z; - public function __construct( - float $x = 0.0, - float $y = 0.0, - float $z = 0.0, - ) { - $this->x = $x; - $this->y = $y; - $this->z = $z; - } -}</pre> + public function __construct( + float $x = 0.0, + float $y = 0.0, + float $z = 0.0, + ) { + $this->x = $x; + $this->y = $y; + $this->z = $z; + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Point { - public function __construct( - public float $x = 0.0, - public float $y = 0.0, - public float $z = 0.0, - ) {} -}</pre> + <?php highlight_php_trimmed( + 'class Point { + public function __construct( + public float $x = 0.0, + public float $y = 0.0, + public float $z = 0.0, + ) {} +}' + );?> </div> </div> </div> @@ -156,32 +168,36 @@ class User <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>class Number { - /** @var int|float */ - private $number; + <?php highlight_php_trimmed( + 'class Number { + /** @var int|float */ + private $number; - /** - * @param float|int $number - */ - public function __construct($number) { - $this->number = $number; - } + /** + * @param float|int $number + */ + public function __construct($number) { + $this->number = $number; + } } -new Number('NaN'); // Нет ошибки</pre> +new Number(\'NaN\'); // Нет ошибки' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>class Number { - public function __construct( - private int|float $number - ) {} + <?php highlight_php_trimmed( + 'class Number { + public function __construct( + private int|float $number + ) {} } -new Number('NaN'); // TypeError</pre> +new Number(\'NaN\'); // TypeError' + );?> </div> </div> </div> @@ -200,27 +216,31 @@ new Number('NaN'); // TypeError</pre> <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>switch (8.0) { - case '8.0': - $result = "О нет!"; - break; - case 8.0: - $result = "То, что я и ожидал"; - break; + <?php highlight_php_trimmed( + 'switch (8.0) { + case \'8.0\': + $result = "О нет!"; + break; + case 8.0: + $result = "То, что я и ожидал"; + break; } echo $result; -//> О нет!</pre> +//> О нет!' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>echo match (8.0) { - '8.0' => "О нет!", - 8.0 => "То, что я и ожидал", + <?php highlight_php_trimmed( + 'echo match (8.0) { + \'8.0\' => "О нет!", + 8.0 => "То, что я и ожидал", }; -//> То, что я и ожидал</pre> +//> То, что я и ожидал' + );?> </div> </div> </div> @@ -243,31 +263,35 @@ echo $result; <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>$country = null; + <?php highlight_php_trimmed( + '$country = null; if ($session !== null) { - $user = $session->user; - - if ($user !== null) { - $address = $user->getAddress(); + $user = $session->user; - if ($address !== null) { - $country = $address->country; - } - } -}</pre> + if ($user !== null) { + $address = $user->getAddress(); + + if ($address !== null) { + $country = $address->country; + } + } +}' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>$country = $session?->user?->getAddress()?->country;</pre> + <?php highlight_php_trimmed( + '$country = $session?->user?->getAddress()?->country;' + );?> </div> </div> </div> <div class="php8-compare__content"> - Вместо проверки на null вы можете использовать последовательность вызовов с новым оператором Nullsafe. Когда + <p>Вместо проверки на null вы можете использовать последовательность вызовов с новым оператором Nullsafe. Когда один из элементов в последовательности возвращает null, выполнение прерывается и вся последовательность возвращает null.</p> </div> @@ -282,14 +306,18 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // true</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // true' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> - <pre>0 == 'foobar' // false</pre> + <?php highlight_php_trimmed( + '0 == \'foobar\' // false' + );?> </div> </div> </div> @@ -308,18 +336,22 @@ if ($session !== null) { <div class="php8-compare__block example-contents"> <div class="php8-compare__label">PHP 7</div> <div class="php8-code phpcode"> -<pre>strlen([]); // Warning: strlen() expects parameter 1 to be string, array given + <?php highlight_php_trimmed( + 'strlen([]); // Warning: strlen() expects parameter 1 to be string, array given -array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0</pre> +array_chunk([], -1); // Warning: array_chunk(): Size parameter expected to be greater than 0' + );?> </div> </div> <div class="php8-compare__arrow"></div> <div class="php8-compare__block example-contents"> <div class="php8-compare__label php8-compare__label_new">PHP 8</div> <div class="php8-code phpcode"> -<pre>strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given + <?php highlight_php_trimmed( + 'strlen([]); // TypeError: strlen(): Argument #1 ($str) must be of type string, array given -array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0</pre> +array_chunk([], -1); // ValueError: array_chunk(): Argument #2 ($length) must be greater than 0' + );?> </div> </div> </div>