{"id":16115,"date":"2021-03-09T12:52:56","date_gmt":"2021-03-09T05:52:56","guid":{"rendered":"https:\/\/blog.tinohost.com\/?p=8159"},"modified":"2021-03-09T12:52:56","modified_gmt":"2021-03-09T05:52:56","slug":"tinohost-ho-tro-php8","status":"publish","type":"post","link":"https:\/\/tino.vn\/blog\/tinohost-ho-tro-php8\/","title":{"rendered":"TinoHost h\u1ed7 tr\u1ee3 PHP 8.0: c\u1ea3i ti\u1ebfn v\u1edbi t\u00ednh n\u0103ng m\u1edbi, hi\u1ec7u su\u1ea5t m\u1edbi"},"content":{"rendered":"<h2 id=\"PHP_8.0_l\u00e0_g\u00ec?\"><strong>PHP 8.0 l\u00e0 g\u00ec?<\/strong><\/h2>\n<h3 id=\"Gi\u1edbi_thi\u1ec7u_PHP_8.0\"><strong>Gi\u1edbi thi\u1ec7u PHP 8.0<\/strong><\/h3>\nPHP \u0111\u01b0\u1ee3c xem l\u00e0 tr\u1ee3 l\u00fd \u0111\u1eafc l\u1ef1c gi\u00fap ng\u01b0\u1eddi d\u00f9ng v\u1eeba c\u00f3 th\u1ec3 l\u00e0m vi\u1ec7c v\u1edbi m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng, v\u1eeba x\u1eed l\u00fd c\u00e1c t\u00ecnh hu\u1ed1ng b\u1ea5t ng\u1edd n\u1ea3y sinh.\nM\u1ed9t phi\u00ean b\u1ea3n PHP ph\u00f9 h\u1ee3p s\u1ebd ph\u00e1t huy t\u1ed1i \u0111a hi\u1ec7u su\u1ea5t website c\u1ee7a b\u1ea1n.\nPhi\u00ean b\u1ea3n PHP m\u1eb7c \u0111\u1ecbnh \u0111\u01b0\u1ee3c k\u00edch ho\u1ea1t cho c\u00e1c domain c\u00f3 s\u1eb5n ho\u1eb7c t\u1ea1o m\u1edbi l\u00e0 PHP 7.4 . Tuy nhi\u00ean m\u1ed9t s\u1ed1 tr\u01b0\u1eddng h\u1ee3p m\u00e3 ngu\u1ed3n y\u00eau c\u1ea7u ho\u1ea1t \u0111\u1ed9ng tr\u00ean tr\u00ean 1 phi\u00ean b\u1ea3n kh\u00e1c, b\u1ea1n c\u00f3 th\u1ec3 \bch\u1ecdn phi\u00ean b\u1ea3n PHP mong mu\u1ed1n cho website.\n\u0110\u01b0\u1ee3c ph\u00e1t h\u00e0nh v\u00e0o ng\u00e0y 26\/11\/2020, PHP 8.0 l\u00e0 m\u1ed9t <a href=\"https:\/\/php.watch\/versions\/8.0\" target=\"_blank\" rel=\"noopener nofollow\" data-schema-attribute=\"\">b\u1ea3n c\u1eadp nh\u1eadt<\/a> v\u1edbi nhi\u1ec1u \u01b0u \u0111i\u1ec3m v\u01b0\u1ee3t b\u1eadc c\u1ee7a ng\u00f4n ng\u1eef PHP. Do PHP 8.0 c\u00f3 nhi\u1ec1u s\u1ef1 thay \u0111\u1ed5i so v\u1edbi phi\u00ean b\u1ea3n tr\u01b0\u1edbc \u0111\u00f3, b\u1ea1n s\u1ebd c\u1ea7n th\u1ef1c hi\u1ec7n m\u1ed9t s\u1ed1 thao t\u00e1c v\u1edbi code c\u1ee7a m\u00ecnh \u0111\u1ec3 c\u00f3 th\u1ec3 v\u1eadn h\u00e0nh tr\u00ean PHP 8.0. Tuy nhi\u00ean, n\u1ebfu b\u1ea1n \u0111\u00e3 c\u1eadp nh\u1eadt t\u1eeb PHP 7.0 tr\u1edf l\u00ean, thao t\u00e1c n\u00e2ng c\u1ea5p l\u00ean PHP 8.0 s\u1ebd kh\u00f4ng qu\u00e1 ph\u1ee9c t\u1ea1p.\n<a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/php-8-2.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8171\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/php-8-2.jpg\" alt=\"tinohost-ho-tro-php8\" width=\"750\" height=\"375\" title=\"\"><\/a>\bNh\u00e0 \u0111\u1ed3ng s\u00e1ng l\u1eadp v\u00e0 nh\u00e0 t\u01b0 v\u1ea5n ch\u00ednh t\u1ea1i PHP Consulting Company &#8211; Stefan Priebsch &#8211; khuy\u00ean r\u1eb1ng vi\u1ec7c chuy\u1ec3n sang PHP 8.0 \u0111\u00f2i h\u1ecfi ph\u1ea3i chu\u1ea9n b\u1ecb nhi\u1ec1u h\u01a1n so v\u1edbi vi\u1ec7c n\u00e2ng c\u1ea5p t\u1eeb PHP 5.x l\u00ean PHP 7, do c\u00e1c v\u1ea5n \u0111\u1ec1 c\u0169 \u0111\u00e3 b\u1ecb x\u00f3a kh\u1ecfi ng\u00f4n ng\u1eef n\u00e0y. <em><strong>(Theo TechRepublic)<\/strong><\/em>\n<h3 id=\"PHP_8.0_c\u00f3_g\u00ec_\u0111\u1eb7c_bi\u1ec7t?\"><strong>PHP 8.0 c\u00f3 g\u00ec \u0111\u1eb7c bi\u1ec7t?<\/strong><\/h3>\nPHP 8.0 s\u1edf h\u1eefu nh\u1eefng t\u00ednh n\u0103ng m\u1edbi g\u1ed3m JIT, named arguments, union types, attributes, constructor property promotion, match expression, nullsafe operator mang \u0111\u1ebfn hi\u1ec7u su\u1ea5t cao l\u1edbn nh\u1edd thay \u0111\u1ed5i c\u00fa ph\u00e1p. \u0110\u1ed3ng th\u1eddi, PHP 8.0 c\u0169ng c\u00f3 nh\u1eefng c\u1ea3i ti\u1ebfn nh\u1ecf trong\u00a0ki\u1ec3u h\u1ec7 th\u1ed1ng, x\u1eed l\u00fd l\u1ed7i v\u00e0 t\u00ednh nh\u1ea5t qu\u00e1n.\n<span style=\"color: #ff0000;\"><strong>Hi\u1ec7n t\u1ea1i, t\u1ea5t c\u1ea3 hosting t\u1ea1i TinoHost \u0111\u1ec1u \u0111\u00e3 b\u1eaft \u0111\u1ea7u h\u1ed7 tr\u1ee3 PHP 8.0.<\/strong><\/span>\n<h2 id=\"8_\u0111i\u1ec3m_n\u1ed5i_b\u1eadt_v\u01b0\u1ee3t_tr\u1ed9i_c\u1ee7a_PHP_8.0\"><strong>8 \u0111i\u1ec3m n\u1ed5i b\u1eadt v\u01b0\u1ee3t tr\u1ed9i c\u1ee7a PHP 8.0<\/strong><\/h2>\n<h3 id=\"#1._\u0110\u1ed1i_s\u1ed1_\u0111\u01b0\u1ee3c_\u0111\u1eb7t_t\u00ean_(Named_arguments)\"><strong>#1. \u0110\u1ed1i s\u1ed1 \u0111\u01b0\u1ee3c \u0111\u1eb7t t\u00ean (Named arguments)<\/strong><\/h3>\nC\u00f3 th\u1ec3 \u0111\u1eb7t t\u00ean khi truy\u1ec1n tham s\u1ed1 l\u00e0 \u0111i\u1ec3m n\u1ed5i b\u1eadt \u0111\u1ea7u ti\u00ean c\u1ee7a PHP 8.0.\nM\u1ed9t function s\u1edf h\u1eefu t\u1eeb 3 tham s\u1ed1 tr\u1edf l\u00ean s\u1ebd d\u1ec5 khi\u1ebfn developer l\u00fang t\u00fang khi s\u1eed d\u1ee5ng v\u00ec kh\u00f4ng nh\u1edb r\u00f5 th\u1ee9 t\u1ef1 truy\u1ec1n ho\u1eb7c \u00fd ngh\u0129a c\u1ee7a t\u1eebng tham s\u1ed1. Kh\u1eafc ph\u1ee5c t\u00ecnh tr\u1ea1ng n\u00e0y, Named arguments s\u1ebd gi\u00fap b\u1ea1n:\n<ul>\n \t<li>Chuy\u1ec3n c\u00e1c gi\u00e1 tr\u1ecb v\u00e0o m\u1ed9t h\u00e0m, ch\u1ec9 x\u00e1c \u0111\u1ecbnh c\u00e1c th\u00f4ng s\u1ed1 b\u1eaft bu\u1ed9c, b\u1ecf qua c\u00e1c th\u00f4ng s\u1ed1 t\u00f9y ch\u1ecdn.<\/li>\n \t<li>C\u00e1c l\u1eadp lu\u1eadn kh\u00f4ng ph\u1ee5 thu\u1ed9c v\u00e0o tr\u1eadt t\u1ef1 v\u00e0 t\u1ef1 ghi l\u1ea1i<\/li>\n<\/ul>\n<h3><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-10.25.30-AM.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8164\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-10.25.30-AM.png\" alt=\"tinohost-ho-tro-php8\" width=\"631\" height=\"139\" title=\"\"><\/a>\n<strong>#2. Thu\u1ed9c t\u00ednh (Attributes)<\/strong><\/h3>\nV\u1edbi c\u00e1c phi\u00ean b\u1ea3n PHP 7 tr\u1edf v\u1ec1 tr\u01b0\u1edbc, ng\u01b0\u1eddi d\u00f9ng ph\u1ea3i khai b\u00e1o c\u00e1c thu\u1ed9c t\u00ednh m\u1ed9t c\u00e1ch r\u00f5 r\u00e0ng.\n\u00d4ng Nikita Popov (t\u00e1c gi\u1ea3 c\u1ee7a RFC) ti\u1ebft l\u1ed9 s\u1ebd r\u00fat g\u1ecdn l\u1ea1i c\u00e1ch khai b\u00e1o c\u00e1c tham s\u1ed1 b\u1eb1ng c\u00e1ch \u0111\u1eb7t trong c\u00e1c tham s\u1ed1 \u1edf h\u00e0m kh\u1edfi t\u1ea1o. Do \u0111\u00f3, thay v\u00ec ch\u00fa th\u00edch PHPDoc, thu\u1ed9c t\u00ednh c\u1ee7a PHP 8.0 gi\u00fap b\u1ea1n s\u1eed d\u1ee5ng si\u00eau d\u1eef li\u1ec7u c\u00f3 c\u1ea5u tr\u00fac v\u1edbi c\u00fa ph\u00e1p g\u1ed1c c\u1ee7a PHP.\n<a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-11.20.03-AM.png\"><img decoding=\"async\" class=\"aligncenter size-jnews-750x536 wp-image-8165\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-11.20.03-AM-701x536.png\" alt=\"tinohost-ho-tro-php8\" width=\"701\" height=\"536\" title=\"\"><\/a>\n<h3 id=\"#3._Khuy\u1ebfn_c\u00e1o_thu\u1ed9c_t\u00ednh_h\u00e0m_d\u1ef1ng_(Constructor_property_promotion)\"><strong>#3. Khuy\u1ebfn c\u00e1o thu\u1ed9c t\u00ednh h\u00e0m d\u1ef1ng (Constructor property promotion)<\/strong><\/h3>\nPHP 8.0 c\u00f3 code \u0111\u1ecbnh ngh\u0129a ng\u1eafn h\u01a1n \u0111\u1ec3 kh\u1edfi t\u1ea1o thu\u1ed9c t\u00ednh.\nRFC n\u00e0y b\u1ed5 sung th\u00eam \u0111\u01b0\u1eddng c\u00fa ph\u00e1p \u0111\u1ec3 t\u1ea1o c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng gi\u00e1 tr\u1ecb ho\u1eb7c \u0111\u1ed1i t\u01b0\u1ee3ng truy\u1ec1n d\u1eef li\u1ec7u. Thay v\u00ec ch\u1ec9 \u0111\u1ecbnh c\u00e1c thu\u1ed9c t\u00ednh c\u1ee7a l\u1edbp v\u00e0 m\u1ed9t h\u00e0m t\u1ea1o cho ch\u00fang, PHP 8.0 c\u00f3 th\u1ec3 k\u1ebft h\u1ee3p ch\u00fang th\u00e0nh m\u1ed9t.\n<a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-11.31.51-AM.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8168\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-11.31.51-AM.png\" alt=\"tinohost-ho-tro-php8\" width=\"576\" height=\"109\" title=\"\"><\/a>\n<h3 id=\"#4._H\u1ee3p_nh\u1ea5t_c\u00e1c_ki\u1ec3u_(Union_types)\"><strong>#4. H\u1ee3p nh\u1ea5t c\u00e1c ki\u1ec3u (Union types)<\/strong><\/h3>\nB\u1ea3n ch\u1ea5t PHP \u0111\u01b0\u1ee3c \u0111\u1ecbnh ki\u1ec3u \u0111\u1ed9ng c\u1ee7a PHP. Do \u0111\u00f3, trong nhi\u1ec1u tr\u01b0\u1eddng h\u1ee3p, ki\u1ec3u li\u00ean h\u1ee3p n\u00e0y s\u1ebd r\u1ea5t h\u1eefu \u00edch.\nThay v\u00ec c\u00e1c ch\u00fa th\u00edch PHPDoc cho s\u1ef1 k\u1ebft h\u1ee3p c\u1ee7a c\u00e1c ki\u1ec3u, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00e1c khai b\u00e1o ki\u1ec3u li\u00ean minh g\u1ed1c \u0111\u01b0\u1ee3c x\u00e1c th\u1ef1c trong th\u1eddi gian ch\u1ea1y.\u00a0 V\u00ec th\u1ebf, m\u1ed9t bi\u1ebfn c\u00f3 th\u1ec3 thu\u1ed9c m\u1ed9t v\u00e0i ki\u1ec3u d\u1eef li\u1ec7u.\n<h3 id=\"#5._Tr\u00ecnh_bi\u00ean_d\u1ecbch_JIT_(Just-in-Time_Compiler)\"><strong>#5. Tr\u00ecnh bi\u00ean d\u1ecbch JIT (Just-in-Time Compiler)<\/strong><\/h3>\n\u0110\u00e2y l\u00e0 m\u1ed9t k\u1ef9 thu\u1eadt \u0111\u01b0\u1ee3c PHP t\u00edch h\u1ee3p v\u00e0o vi\u1ec7c bi\u00ean d\u1ecbch code PHP th\u00e0nh m\u00e3 m\u00e1y. \b\n\u0110i\u1ec3m c\u1ea3i ti\u1ebfn n\u1ed5i b\u1eadt c\u1ee7a JIT ch\u00ednh l\u00e0 tr\u00ecnh bi\u00ean d\u1ecbch m\u1edbi b\u1ed5 sung JIT Compiler gi\u00fap PHP 8.0 \u0111\u1ea1t hi\u1ec7u su\u1ea5t cao g\u1ea5p 1,5 \u2013 2 l\u1ea7n so v\u1edbi PHP 7. Hi\u1ec7u su\u1ea5t \u1ee9ng d\u1ee5ng ngang b\u1eb1ng ho\u1eb7c t\u1ed1t h\u01a1n v\u1edbi PHP 7.4.\nTrong hai c\u00f4ng c\u1ee5 bi\u00ean d\u1ecbch JIT, Tracing JIT h\u1ee9a h\u1eb9n mang \u0111\u1ebfn hi\u1ec7u su\u1ea5t cao g\u1ea5p 3 l\u1ea7n tr\u00ean c\u00e1c \u0111i\u1ec3m chu\u1ea9n t\u1ed5ng h\u1ee3p.\nB\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o Bi\u1ec3u \u0111\u1ed3 so s\u00e1nh t\u1ed1c \u0111\u1ed9 c\u1ee7a PHP khi c\u00f3 JIT v\u00e0 kh\u00f4ng c\u00f3 JIT nh\u01b0 h\u00ecnh b\u00ean d\u01b0\u1edbi:\n<a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/PHP1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8163\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/PHP1.png\" alt=\"tinohost-ho-tro-php8\" width=\"750\" height=\"381\" title=\"\"><\/a>Trong \u0111\u00f3:\n<ul>\n \t<li>bench.php, micro_bech.php, N-body, Mandelbrot \u0111\u1ec1u l\u00e0 c\u00e1c b\u00e0i test tr\u00ean \u1ee9ng d\u1ee5ng PHP \u0111\u01a1n gi\u1ea3n.<\/li>\n \t<li>C\u00e1c b\u00e0i test c\u00f2n l\u1ea1i, l\u1ea7n l\u01b0\u1ee3t test tr\u00ean c\u00e1c \u1ee9ng d\u1ee5ng PHP c\u00f3 \u0111\u1ed9 ph\u1ee9c t\u1ea1p t\u0103ng d\u1ea7n.<\/li>\n \t<li>\u0110\u01b0\u1eddng m\u00e0u \u0111en, k\u1ebb d\u1ecdc \u1edf bi\u1ec3u \u0111\u1ed3 tr\u00ean l\u00e0 ng\u01b0\u1ee1ng t\u1ed1i \u0111a khi PHP kh\u00f4ng s\u1eed d\u1ee5ng JIT.<\/li>\n<\/ul>\n<strong>Nh\u1eadn x\u00e9t:\u00a0<\/strong>\n<ul>\n \t<li>\u00c1p d\u1ee5ng JIT ch\u1ec9 \u0111\u1ea1t hi\u1ec7u n\u0103ng cao v\u1edbi \u1ee9ng d\u1ee5ng PHP \u0111\u01a1n gi\u1ea3n.<\/li>\n \t<li>Ng\u01b0\u1ee3c l\u1ea1i, JIT kh\u00f4ng mang l\u1ea1i nhi\u1ec1u \u01b0u \u0111i\u1ec3m v\u1edbi c\u00e1c \u1ee9ng d\u1ee5ng PHP ph\u1ee9c t\u1ea1p, s\u1eed d\u1ee5ng c\u00e1c Framework, CMS ph\u1ed5 bi\u1ebfn nh\u01b0 WordPress, Symfony, &#8230;<\/li>\n<\/ul>\n<h3 id=\"#6._To\u00e1n_t\u1eed_Nullsafe_(Nullsafe_operator)\"><strong>#6. To\u00e1n t\u1eed Nullsafe (Nullsafe operator)<\/strong><\/h3>\nV\u1edbi c\u00e1c phi\u00ean b\u1ea3n PHP tr\u01b0\u1edbc, \u0111\u1ec3 tr\u00e1nh l\u1ed7i, ta th\u01b0\u1eddng ki\u1ec3m tra gi\u00e1 tr\u1ecb c\u00f3 kh\u00e1c <strong>null<\/strong> hay kh\u00f4ng tr\u01b0\u1edbc khi truy c\u1eadp. Nullsafe operator c\u1ee7a PP 8.0 cho ph\u00e9p b\u1ea1n truy c\u1eadp v\u00e0o gi\u00e1 tr\u1ecb c\u1ee7a m\u1ed9t thu\u1ed9c t\u00ednh \u1edf gi\u00e1 tr\u1ecb <strong>null<\/strong> m\u00e0 kh\u00f4ng b\u1ecb l\u1ed7i.\nS\u1eed d\u1ee5ng m\u1ed9t chu\u1ed7i c\u00e1c cu\u1ed9c g\u1ecdi v\u1edbi to\u00e1n t\u1eed nullsafe m\u1edbi c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c xem l\u00e0 ph\u01b0\u01a1ng \u00e1n thay th\u1ebf cho \u0111i\u1ec1u ki\u1ec7n ki\u1ec3m tra <strong>null<\/strong>.\nKhi \u0111\u00e1nh gi\u00e1 m\u1ed9t ph\u1ea7n t\u1eed trong chu\u1ed7i fails, qu\u00e1 tr\u00ecnh th\u1ef1c thi c\u1ee7a to\u00e0n b\u1ed9 chu\u1ed7i s\u1ebd b\u1ecb h\u1ee7y b\u1ecf. L\u00fac n\u00e0y, to\u00e0n b\u1ed9 chu\u1ed7i \u0111\u01b0\u1ee3c g\u00e1n l\u00e0 <strong>null<\/strong>.\nThay v\u00ec:\n<code><strong>$startDate = $booking-&gt;getStartDate();<\/strong><\/code>\n<code><strong>$dateAsString = $startDate ? $startDate-&gt;asDateTimeString() : null;<\/strong><\/code>\nB\u1ea1n s\u1ebd:\n<strong><code>$dateAsString = $booking-&gt;getStartDate()?-&gt;asDateTimeString();<\/code><\/strong>\n<h3 id=\"#7._Bi\u1ec3u_th\u1ee9c_\u0111\u1ed1i_s\u00e1nh_(Match_expression)\"><strong>#7. Bi\u1ec3u th\u1ee9c \u0111\u1ed1i s\u00e1nh (Match expression)<\/strong><\/h3>\nT\u01b0\u01a1ng t\u1ef1 nh\u01b0 switch, Match expression l\u00e0 m\u1ed9t bi\u1ec3u th\u1ee9c, k\u1ebft qu\u1ea3 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong m\u1ed9t bi\u1ebfn ho\u1eb7c \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1.\nC\u00e1c nh\u00e1nh so s\u00e1nh ch\u1ec9 h\u1ed7 tr\u1ee3 c\u00e1c bi\u1ec3u th\u1ee9c m\u1ed9t d\u00f2ng v\u00e0 kh\u00f4ng c\u1ea7n \bd\u1ea5u ng\u1eaft \u0111\u1ec3 k\u1ebft th\u00fac l\u1ec7nh. Match c\u00f3 th\u1ec3 k\u1ebft h\u1ee3p c\u00e1c \u0111i\u1ec1u ki\u1ec7n, s\u1eed d\u1ee5ng so s\u00e1nh ki\u1ec3u nghi\u00eam ng\u1eb7t v\u00e0 kh\u00f4ng th\u1ef1c hi\u1ec7n b\u1ea5t k\u1ef3 ki\u1ec3u \u00e9p bu\u1ed9c n\u00e0o.\n<h3 id=\"#8._Nh\u1ea5t_qu\u00e1n_l\u1ed7i_cho_c\u00e1c_ch\u1ee9c_n\u0103ng_n\u1ed9i_b\u1ed9_(Consistent_type_errors_for_internal_functions)\"><a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-12.02.09-PM.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8169\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-12.02.09-PM.png\" alt=\"tinohost-ho-tro-php8\" width=\"592\" height=\"167\" title=\"\"><\/a><strong>#8. Nh\u1ea5t qu\u00e1n l\u1ed7i cho c\u00e1c ch\u1ee9c n\u0103ng n\u1ed9i b\u1ed9 (Consistent type errors for internal functions)<\/strong><\/h3>\nC\u00e1c h\u00e0m do ng\u01b0\u1eddi d\u00f9ng \u0111\u1ecbnh ngh\u0129a trong PHP s\u1ebd \u0111\u01b0a ra <strong>TypeErro<\/strong>r. Trong khi \u0111\u00f3, c\u00e1c h\u00e0m n\u1ed9i b\u1ed9 s\u1ebd ph\u00e1t ra c\u1ea3nh b\u00e1o v\u00e0 tr\u1ea3 v\u1ec1 null. T\u1eeb phi\u00ean b\u1ea3n PHP 8.0, h\u00e0nh vi c\u1ee7a c\u00e1c h\u00e0m n\u1ed9i b\u1ed9 \u0111\u00e3 \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n nh\u1ea5t qu\u00e1n.\nN\u1ebfu x\u00e1c th\u1ef1c c\u00e1c tham s\u1ed1 kh\u00f4ng th\u00e0nh c\u00f4ng, c\u00e1c ch\u1ee9c n\u0103ng n\u1ed9i b\u1ed9 s\u1ebd \u0111\u01b0a ra <strong>Exception<\/strong>.\nHi\u1ec3u c\u00e1ch kh\u00e1c, nh\u1eefng c\u1ea3nh b\u00e1o li\u00ean quan \u0111\u1ebfn check ki\u1ec3u d\u1eef li\u1ec7u parameter, s\u1ebd \u0111\u01b0\u1ee3c PHP chuy\u1ec3n \u0111\u1ed5i th\u00e0nh <strong>Exception<\/strong>.\n<a href=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-12.41.22-PM.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8170\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/03\/Screen-Shot-2021-03-09-at-12.41.22-PM.png\" alt=\"tinohost-ho-tro-php8\" width=\"750\" height=\"291\" title=\"\"><\/a>C\u00f2n nhi\u1ec1u t\u00ednh n\u0103ng \u0111\u00e3 \u0111\u01b0\u1ee3c c\u1ea3i ti\u1ebfn, m\u1eddi b\u1ea1n tr\u1ea3i nghi\u1ec7m v\u00e0 chia s\u1ebb v\u1edbi TinoHost nh\u00e9!\n<span style=\"font-weight: 400;\">M\u1ecdi th\u1eafc m\u1eafc v\u00e0 g\u00f3p \u00fd li\u00ean quan, xin vui l\u00f2ng<\/span><a href=\"https:\/\/tinohost.com\/lien-he\/\" target=\"_blank\" rel=\"noopener\"> <span style=\"font-weight: 400;\">li\u00ean h\u1ec7 ngay TinoHost<\/span><\/a><span style=\"font-weight: 400;\"> \u0111\u1ec3 \u0111\u01b0\u1ee3c t\u01b0 v\u1ea5n chi ti\u1ebft ho\u1eb7c<\/span><a href=\"https:\/\/www.facebook.com\/tinohostdotcom\/\" rel=\"nofollow noopener\" target=\"_blank\"> <span style=\"font-weight: 400;\">Fanpage<\/span><\/a><span style=\"font-weight: 400;\"> \u0111\u1ec3 c\u1eadp nh\u1eadt nh\u1eefng th\u00f4ng tin m\u1edbi nh\u1ea5t.<\/span>\n<span style=\"font-weight: 400;\">V\u1edbi b\u1ec1 d\u00e0y kinh nghi\u1ec7m h\u01a1n 5 n\u0103m cung c\u1ea5p hosting, d\u1ecbch v\u1ee5 cho thu\u00ea m\u00e1y ch\u1ee7, c\u00e1c d\u1ecbch v\u1ee5 li\u00ean quan \u0111\u1ebfn t\u00ean mi\u1ec1n v\u00e0 b\u1ea3o m\u1eadt website, h\u00e3y \u0111\u1ec3 TinoHost \u0111\u1ed3ng h\u00e0nh c\u00f9ng b\u1ea1n tr\u00ean con \u0111\u01b0\u1eddng kh\u1eb3ng \u0111\u1ecbnh th\u01b0\u01a1ng hi\u1ec7u tr\u00ean b\u1ea3n \u0111\u1ed3 c\u00f4ng ngh\u1ec7 to\u00e0n c\u1ea7u!<\/span>\n<b><\/b>\n<ul>\n \t<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><\/span><span style=\"font-weight: 400;\">\n<\/span><span style=\"font-weight: 400;\"><\/span><\/li>\n \t<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><\/span><span style=\"font-weight: 400;\">\n<\/span><span style=\"font-weight: 400;\"><\/span><\/li>\n \t<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"><\/span><\/li>\n \t<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Website: <\/span><a href=\"https:\/\/tinohost.com\/?aff=447\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\"><\/span><\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>PHP 8.0 l\u00e0 g\u00ec? Gi\u1edbi thi\u1ec7u PHP 8.0 PHP \u0111\u01b0\u1ee3c xem l\u00e0 tr\u1ee3 l\u00fd \u0111\u1eafc l\u1ef1c gi\u00fap ng\u01b0\u1eddi d\u00f9ng v\u1eeba c\u00f3 th\u1ec3 l\u00e0m vi\u1ec7c v\u1edbi m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng, v\u1eeba x\u1eed l\u00fd c\u00e1c t\u00ecnh hu\u1ed1ng b\u1ea5t ng\u1edd n\u1ea3y sinh. M\u1ed9t phi\u00ean b\u1ea3n PHP ph\u00f9 h\u1ee3p s\u1ebd ph\u00e1t huy t\u1ed1i \u0111a hi\u1ec7u su\u1ea5t website c\u1ee7a b\u1ea1n. Phi\u00ean [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":16116,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[5685,5686,5687],"class_list":["post-16115","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-php","tag-php-8-0","tag-tinohost"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/16115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=16115"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/16115\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16116"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=16115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/categories?post=16115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=16115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}