1:HL["/_next/static/media/560d0dc937e89811-s.p.woff2",{"as":"font","type":"font/woff2"}] 2:HL["/_next/static/css/2e92341f2f2a549e.css",{"as":"style"}] 0:["990hTVHkZlVsRanvA0-KC",[[["",{"children":["blog",{"children":[["slug","php8-new-features-and-updates","c"],{"children":["__PAGE__?{\"slug\":[\"php8-new-features-and-updates\"]}",{}]}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2e92341f2f2a549e.css","precedence":"next"}]],"$L4"]]]] 5:HL["/_next/static/css/aa77ab9bba161dd5.css",{"as":"style"}] 6:I{"id":8464,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","504:static/chunks/504-3bf38d4755258f20.js","185:static/chunks/app/layout-a3c0484fb4b40d70.js"],"name":"ThemeProviders","async":false} 7:I{"id":3015,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","504:static/chunks/504-3bf38d4755258f20.js","185:static/chunks/app/layout-a3c0484fb4b40d70.js"],"name":"","async":false} 8:I{"id":3657,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","504:static/chunks/504-3bf38d4755258f20.js","185:static/chunks/app/layout-a3c0484fb4b40d70.js"],"name":"KBarSearchProvider","async":false} 9:I{"id":6685,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","797:static/chunks/app/blog/[...slug]/page-3271df622a55882d.js"],"name":"","async":false} a:I{"id":7005,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","504:static/chunks/504-3bf38d4755258f20.js","185:static/chunks/app/layout-a3c0484fb4b40d70.js"],"name":"KBarButton","async":false} b:I{"id":6914,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","504:static/chunks/504-3bf38d4755258f20.js","185:static/chunks/app/layout-a3c0484fb4b40d70.js"],"name":"","async":false} c:I{"id":8766,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","504:static/chunks/504-3bf38d4755258f20.js","185:static/chunks/app/layout-a3c0484fb4b40d70.js"],"name":"","async":false} d:I{"id":7767,"chunks":["272:static/chunks/webpack-ab432321c71a0084.js","971:static/chunks/fd9d1056-3a33dcaeb8d53e3c.js","596:static/chunks/596-58227000ca6846a8.js"],"name":"default","async":false} e:I{"id":7920,"chunks":["272:static/chunks/webpack-ab432321c71a0084.js","971:static/chunks/fd9d1056-3a33dcaeb8d53e3c.js","596:static/chunks/596-58227000ca6846a8.js"],"name":"default","async":false} 4:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"PHP 8: New Features and Improvements | akbv - Atanas Korabov"}],["$","meta","2",{"name":"description","content":"Explore the dynamics of PHP 8, a groundbreaking update in the realm of web development. Discover PHP 8`s functionalities and updates including Traits, Array Destructuring, Arrow Functions, and more. Understand how PHP 8 offers improved type safety, memory efficiency and increased performance, revolutionizing the essentials of web development."}],["$","meta","3",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","4",{"name":"robots","content":"index, follow"}],["$","meta","5",{"name":"googlebot","content":"index, follow, max-video-preview:-1, max-image-preview:large, max-snippet:-1"}],["$","link","6",{"rel":"canonical","href":"https://akbv.dev/blog/php8-new-features-and-updates"}],["$","link","7",{"rel":"alternate","type":"application/rss+xml","href":"https://akbv.dev/feed.xml"}],["$","meta","8",{"property":"og:title","content":"PHP 8: New Features and Improvements"}],["$","meta","9",{"property":"og:description","content":"Explore the dynamics of PHP 8, a groundbreaking update in the realm of web development. Discover PHP 8`s functionalities and updates including Traits, Array Destructuring, Arrow Functions, and more. Understand how PHP 8 offers improved type safety, memory efficiency and increased performance, revolutionizing the essentials of web development."}],["$","meta","10",{"property":"og:url","content":"https://akbv.dev/blog/php8-new-features-and-updates"}],["$","meta","11",{"property":"og:site_name","content":"akbv - Atanas Korabov"}],["$","meta","12",{"property":"og:locale","content":"en_US"}],["$","meta","13",{"property":"og:image","content":"https://akbv.dev/static/images/php8-update-binoculars.png"}],["$","meta","14",{"property":"og:type","content":"article"}],["$","meta","15",{"property":"article:published_time","content":"2023-09-23T00:00:00.000Z"}],["$","meta","16",{"property":"article:modified_time","content":"2023-09-23T00:00:00.000Z"}],["$","meta","17",{"property":"article:author","content":"Atanas Korabov"}],["$","meta","18",{"name":"twitter:card","content":"summary_large_image"}],["$","meta","19",{"name":"twitter:title","content":"PHP 8: New Features and Improvements"}],["$","meta","20",{"name":"twitter:description","content":"Explore the dynamics of PHP 8, a groundbreaking update in the realm of web development. Discover PHP 8`s functionalities and updates including Traits, Array Destructuring, Arrow Functions, and more. Understand how PHP 8 offers improved type safety, memory efficiency and increased performance, revolutionizing the essentials of web development."}],["$","meta","21",{"name":"twitter:image","content":"https://akbv.dev/static/images/php8-update-binoculars.png"}],["$","meta","22",{"name":"next-size-adjust"}]] 3:[["$","html",null,{"lang":"en-us","className":"__variable_8c5df3 scroll-smooth","suppressHydrationWarning":true,"children":[["$","link",null,{"rel":"apple-touch-icon","sizes":"76x76","href":"/static/favicons/apple-touch-icon.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"32x32","href":"/static/favicons/favicon-32x32.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"16x16","href":"/static/favicons/favicon-16x16.png"}],["$","link",null,{"rel":"manifest","href":"/static/favicons/site.webmanifest"}],["$","link",null,{"rel":"mask-icon","href":"/static/favicons/safari-pinned-tab.svg","color":"#5bbad5"}],["$","meta",null,{"name":"msapplication-TileColor","content":"#000000"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"#fff"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"#000"}],["$","link",null,{"rel":"alternate","type":"application/rss+xml","href":"/feed.xml"}],["$","body",null,{"className":"bg-white text-black antialiased dark:bg-gray-950 dark:text-white","children":["$","$L6",null,{"children":[["$undefined","$undefined","$undefined","$undefined",[["$","$L7",null,{"strategy":"afterInteractive","src":"https://www.googletagmanager.com/gtag/js?id=G-E6QL49GCHT"}],["$","$L7",null,{"strategy":"afterInteractive","id":"ga-script","children":"\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', 'G-E6QL49GCHT');\n "}]]],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":["$","div",null,{"className":"flex h-screen flex-col justify-between font-sans","children":[["$","$L8",null,{"kbarConfig":{"searchDocumentsPath":"search.json"},"children":[["$","header",null,{"className":"flex items-center justify-between py-10","children":[["$","div",null,{"children":["$","$L9",null,{"href":"/","aria-label":"akbv.dev","children":["$","div",null,{"className":"flex items-center justify-between","children":[["$","div",null,{"className":"mr-3","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","xmlnsXlink":"http://www.w3.org/1999/xlink","width":53.87,"height":43.61,"viewBox":"344.564 330.278 111.737 91.218","children":[["$","defs",null,{"children":[["$","path",null,{"id":"logo_svg__a","d":"M453.3 331.28v28.57l-64.66 58.65v-30.08l64.66-57.14Z"}],["$","path",null,{"id":"logo_svg__c","d":"M410.23 331.28v28.57l-64.67 58.65v-30.08l64.67-57.14Z"}],["$","linearGradient",null,{"id":"logo_svg__b","x1":"0%","x2":"100%","y1":"0%","y2":"0%","children":[["$","stop",null,{"offset":"0%","style":{"stopColor":"#00ff8f"}}],["$","stop",null,{"offset":"100%","style":{"stopColor":"#00a1ff"}}]]}]]}],["$","use",null,{"xlinkHref":"#logo_svg__a","fill":"url(#logo_svg__b)"}],["$","use",null,{"xlinkHref":"#logo_svg__c","fill":"url(#logo_svg__b)"}]]}]}],["$","div",null,{"className":"hidden h-6 text-2xl font-semibold sm:block","children":"akbv.dev"}]]}]}]}],["$","div",null,{"className":"flex items-center leading-5 space-x-4 sm:space-x-6","children":[[["$","$L9",null,{"href":"/blog","className":"hidden sm:block font-medium text-gray-900 dark:text-gray-100","children":"Blog"}],["$","$L9",null,{"href":"/tags","className":"hidden sm:block font-medium text-gray-900 dark:text-gray-100","children":"Tags"}],["$","$L9",null,{"href":"/projects","className":"hidden sm:block font-medium text-gray-900 dark:text-gray-100","children":"Projects"}],["$","$L9",null,{"href":"/about","className":"hidden sm:block font-medium text-gray-900 dark:text-gray-100","children":"About"}]],["$","$La",null,{"aria-label":"Search","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","fill":"none","viewBox":"0 0 24 24","strokeWidth":1.5,"stroke":"currentColor","className":"text-gray-900 dark:text-gray-100 h-6 w-6","children":["$","path",null,{"strokeLinecap":"round","strokeLinejoin":"round","d":"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"}]}]}],["$","$Lb",null,{}],["$","$Lc",null,{}]]}]]}],["$","main",null,{"className":"mb-auto","children":["$","$Ld",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Le",null,{}],"templateStyles":"$undefined","notFound":["$","div",null,{"className":"flex flex-col items-start justify-start md:mt-24 md:flex-row md:items-center md:justify-center md:space-x-6","children":[["$","div",null,{"className":"space-x-2 pb-8 pt-6 md:space-y-5","children":["$","h1",null,{"className":"text-6xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 md:border-r-2 md:px-6 md:text-8xl md:leading-14","children":"404"}]}],["$","div",null,{"className":"max-w-md","children":[["$","p",null,{"className":"mb-4 text-xl font-bold leading-normal md:text-2xl","children":"Sorry we couldn't find this page."}],["$","p",null,{"className":"mb-8","children":"But dont worry, you can find plenty of other things on our homepage."}],["$","$L9",null,{"href":"/","className":"focus:shadow-outline-blue inline rounded-lg border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium leading-5 text-white shadow transition-colors duration-150 hover:bg-blue-700 focus:outline-none dark:hover:bg-blue-500","children":"Back to homepage"}]]}]]}],"notFoundStyles":[],"childProp":{"current":["$","$Ld",null,{"parallelRouterKey":"children","segmentPath":["children","blog","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Le",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$Ld",null,{"parallelRouterKey":"children","segmentPath":["children","blog","children",["slug","php8-new-features-and-updates","c"],"children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Le",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Lf",null],"segment":"__PAGE__?{\"slug\":[\"php8-new-features-and-updates\"]}"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/aa77ab9bba161dd5.css","precedence":"next"}]]}],"segment":["slug","php8-new-features-and-updates","c"]},"styles":[]}],"segment":"blog"},"styles":[]}]}]]}],["$","footer",null,{"children":["$","div",null,{"className":"mt-16 flex flex-col items-center","children":[["$","div",null,{"className":"mb-3 flex space-x-4","children":[["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"mailto:address@yoursite.com","children":[["$","span",null,{"className":"sr-only","children":"mail"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 20 20","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":[["$","path",null,{"d":"M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z"}],["$","path",null,{"d":"M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z"}]]}]]}],["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/a-kbv","children":[["$","span",null,{"className":"sr-only","children":"github"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":["$","path",null,{"d":"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"}]}]]}],["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://facebook.com","children":[["$","span",null,{"className":"sr-only","children":"facebook"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":["$","path",null,{"d":"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"}]}]]}],null,["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://www.linkedin.com/in/atanaskorabov/","children":[["$","span",null,{"className":"sr-only","children":"linkedin"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":["$","path",null,{"d":"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.064 2.064 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"}]}]]}],["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://twitter.com/AtanasKorabov","children":[["$","span",null,{"className":"sr-only","children":"twitter"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":["$","path",null,{"d":"M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"}]}]]}]]}],["$","div",null,{"className":"mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400","children":[["$","div",null,{"children":"Atanas Korabov"}],["$","div",null,{"children":" • "}],["$","div",null,{"children":"© 2023"}],["$","div",null,{"children":" • "}],["$","$L9",null,{"href":"/","children":"akbv - Atanas Korabov"}]]}],["$","div",null,{"className":"mb-8 text-sm text-gray-500 dark:text-gray-400","children":["$","a",null,{"target":"_blank","rel":"noopener noreferrer","href":"https://github.com/timlrx/tailwind-nextjs-starter-blog","children":"Tailwind Nextjs Theme"}]}]]}]}]]}]}]]}]}]]}],null] 10:I{"id":2630,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","797:static/chunks/app/blog/[...slug]/page-3271df622a55882d.js"],"name":"","async":false} 11:I{"id":2529,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","797:static/chunks/app/blog/[...slug]/page-3271df622a55882d.js"],"name":"","async":false} 12:I{"id":5940,"chunks":["685:static/chunks/685-3720320f1c2a7834.js","797:static/chunks/app/blog/[...slug]/page-3271df622a55882d.js"],"name":"","async":false} f:[["$","script",null,{"type":"application/ld+json","dangerouslySetInnerHTML":{"__html":"{\"@context\":\"https://schema.org\",\"@type\":\"BlogPosting\",\"headline\":\"PHP 8: New Features and Improvements\",\"datePublished\":\"2023-09-23T00:00:00.000Z\",\"dateModified\":\"2023-09-23T00:00:00.000Z\",\"description\":\"Explore the dynamics of PHP 8, a groundbreaking update in the realm of web development. Discover PHP 8`s functionalities and updates including Traits, Array Destructuring, Arrow Functions, and more. Understand how PHP 8 offers improved type safety, memory efficiency and increased performance, revolutionizing the essentials of web development.\",\"url\":\"https://akbv.dev/blog/php8-new-features-and-updates\",\"author\":[{\"@type\":\"Person\",\"name\":\"Atanas Korabov\"}]}"}}],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":[["$","$L10",null,{}],["$","article",null,{"children":["$","div",null,{"children":[["$","header",null,{"children":["$","div",null,{"className":"space-y-1 border-b border-gray-200 pb-10 text-center dark:border-gray-700","children":[["$","dl",null,{"children":["$","div",null,{"children":[["$","dt",null,{"className":"sr-only","children":"Published on"}],["$","dd",null,{"className":"text-base font-medium leading-6 text-gray-500 dark:text-gray-400","children":["$","time",null,{"dateTime":"2023-09-23T00:00:00.000Z","children":"September 23, 2023"}]}]]}]}],["$","div",null,{"children":["$","h1",null,{"className":"text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:text-5xl md:leading-14","children":"PHP 8: New Features and Improvements"}]}],["$","div",null,{"className":"flex justify-center gap-5 py-4","children":[["$","span",null,{"className":"flex items-center gap-1.5","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","aria-hidden":"true","className":"h-5 w-5","children":["$undefined",[["$","path","0",{"strokeLinecap":"round","strokeLinejoin":"round","d":"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],1510," words"]}],["$","span",null,{"className":"flex items-center gap-1.5","children":[["$","svg",null,{"stroke":"currentColor","fill":"none","strokeWidth":"2","viewBox":"0 0 24 24","aria-hidden":"true","className":"h-5 w-5","children":["$undefined",[["$","path","0",{"strokeLinecap":"round","strokeLinejoin":"round","d":"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z","children":"$undefined"}]]],"style":{"color":"$undefined"},"height":"1em","width":"1em","xmlns":"http://www.w3.org/2000/svg"}],"8 min read"]}]]}]]}]}],["$","div",null,{"className":"grid-rows-[auto_1fr] divide-y divide-gray-200 pb-8 dark:divide-gray-700 xl:divide-y-0","children":[["$","div",null,{"className":"divide-y divide-gray-200 dark:divide-gray-700 xl:col-span-3 xl:row-span-2 xl:pb-0","children":["$","div",null,{"className":"prose max-w-none pb-8 pt-10 dark:prose-invert","children":[["$","h1",null,{"id":"php-8--key-changes-and-features","children":[["$","a",null,{"href":"#php-8--key-changes-and-features","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"PHP 8 : Key Changes and Features"]}],["$","p",null,{"children":"If you stopped paying attention to PHP updates after 2012, you'd be forgiven for thinking that PHP is dead. However, PHP is alive and kicking, having undergone several vital improvements since 2012 with the introduction of PHP 5.4. Don't believe it? Let's look at some of the many language changes that PHP has undergone, right up to PHP 8."}],["$","h2",null,{"id":"traits","children":[["$","a",null,{"href":"#traits","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Traits:"]}],["$","p",null,{"children":"PHP 5.4 brought an end to the monotonous rewriting of the same method body or abusing inheritance by introducing Traits, which favor composition over inheritance. In layman's terms, Traits are chunks of code that you can use in different class without having to duplicate the code or inherit classes."}],["$","h4",null,{"id":"old-way","children":[["$","a",null,{"href":"#old-way","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Old way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"log"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$msg"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//log message"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Bar"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"log"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$msg"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//log message"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h4",null,{"id":"new-way","children":[["$","a",null,{"href":"#new-way","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"New way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"trait"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Logger"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"log"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$msg"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//log message"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"use"}]," ",["$","span",null,{"className":"token package","children":"Logger"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Bar"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"use"}]," ",["$","span",null,{"className":"token package","children":"Logger"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h2",null,{"id":"short-array-syntax","children":[["$","a",null,{"href":"#short-array-syntax","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Short Array Syntax:"]}],["$","p",null,{"children":"In PHP 5.4, no more writing out 'array' like a caveman; you can simply use square brackets for an array."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$names"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token keyword","children":"array"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token single-quoted-string string","children":"'Jeffrey'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'John'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Mary'"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}]," ",["$","span",null,{"className":"token comment","children":"// Old way"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$names"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token single-quoted-string string","children":"'Jeffrey'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'John'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Mary'"}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":";"}]," ",["$","span",null,{"className":"token comment","children":"// New way"}],"\n"]}]]}]}],["$","h2",null,{"id":"array-destructuring","children":[["$","a",null,{"href":"#array-destructuring","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Array Destructuring:"]}],["$","p",null,{"children":"Instead of assigning an array to a temporary variable to define multiple variables, now, you can use array destructuring."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$array"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token keyword","children":"array"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token single-quoted-string string","children":"'a'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'b'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'c'"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$a"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$names"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token number","children":"0"}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$b"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$names"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token number","children":"1"}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$c"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$names"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token number","children":"2"}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token comment","children":"// turns into this"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$array"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token keyword","children":"array"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token single-quoted-string string","children":"'a'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'b'"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'c'"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token variable","children":"$$a"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$b"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$c"}],["$","span",null,{"className":"token punctuation","children":"]"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$names"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]]}]}],["$","h2",null,{"id":"first-class-variadic-functions","children":[["$","a",null,{"href":"#first-class-variadic-functions","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"First-class Variadic Functions"]}],["$","p",null,{"children":"With PHP 8, it's possible to make use of first-class variadic functions, allowing you to pass as many arguments to a function as you might need, using the '...' operator."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"sum"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token operator","children":"..."}],["$","span",null,{"className":"token variable","children":"$$numbers"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"return"}]," ",["$","span",null,{"className":"token function","children":"array_sum"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$numbers"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"echo"}]," ",["$","span",null,{"className":"token function","children":"sum"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token number","children":"1"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token number","children":"2"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token number","children":"3"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token number","children":"4"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}]," ",["$","span",null,{"className":"token comment","children":"// Outputs 10"}],"\n"]}]]}]}],["$","h2",null,{"id":"arrow-functions","children":[["$","a",null,{"href":"#arrow-functions","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Arrow Functions"]}],["$","p",null,{"children":"Those familiar with JavaScript will feel at home with PHP 8's introduction of arrow functions. These functions make use of the 'fn' keyword to define a new function in a more compact and readable format."}],["$","h4",null,{"id":"old-way-1","children":[["$","a",null,{"href":"#old-way-1","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Old way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token function","children":"array_map"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword","children":"function"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$item"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"return"}]," ",["$","span",null,{"className":"token variable","children":"$$item"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"id"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$items"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]]}]}],["$","h4",null,{"id":"new-way-1","children":[["$","a",null,{"href":"#new-way-1","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"New way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token function","children":"array_map"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword","children":"fn"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$item"}],["$","span",null,{"className":"token punctuation","children":")"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token variable","children":"$$item"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"id"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$items"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]}]}],["$","h2",null,{"id":"null-coalescing-operator","children":[["$","a",null,{"href":"#null-coalescing-operator","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Null Coalescing Operator"]}],["$","p",null,{"children":"PHP 7 first gave us the null coalescing operator, allowing for more concise and readable code. This operator returns its first operand if it exists and is not null; otherwise, it returns its second operand."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$username"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token global","children":"$$_GET"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token single-quoted-string string","children":"'user'"}],["$","span",null,{"className":"token punctuation","children":"]"}]," ",["$","span",null,{"className":"token operator","children":"??"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'nobody'"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]}]}],["$","p",null,{"children":"PHP 7.4 further improved this by bringing the null coalescing assignment operator '??='. This operator will leave the variable as-is if it's already set; otherwise, it will assign the given value."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token global","children":"$$_GET"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token single-quoted-string string","children":"'user'"}],["$","span",null,{"className":"token punctuation","children":"]"}]," ",["$","span",null,{"className":"token operator","children":"??="}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'nobody'"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]}]}],["$","h2",null,{"id":"null-chaining-operator","children":[["$","a",null,{"href":"#null-chaining-operator","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Null Chaining Operator"]}],["$","p",null,{"children":"The null chaining operator introduced in PHP 8 significant improvements in operating with objects and properties. It will stop the chain and return null if a null value is encountered."}],["$","p",null,{"children":"Old way:"}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$age"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$user"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"age"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$age"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$age"}]," ",["$","span",null,{"className":"token operator","children":"?"}]," ",["$","span",null,{"className":"token variable","children":"$$age"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token function","children":"format"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token single-quoted-string string","children":"'Y-m-d'"}],["$","span",null,{"className":"token punctuation","children":")"}]," ",["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token class-name return-type","children":"null"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]]}]}],["$","p",null,{"children":"New way:"}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$age"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$user"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"age"}],["$","span",null,{"className":"token operator","children":"?->"}],["$","span",null,{"className":"token function","children":"format"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token single-quoted-string string","children":"'Y-m-d'"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]}]}],["$","h2",null,{"id":"named-arguments","children":[["$","a",null,{"href":"#named-arguments","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Named Arguments"]}],["$","p",null,{"children":"Named arguments give you the freedom to skip optional parameters without the need to insert a null value, keeping your function calls cleaner and more self-documented."}],["$","h4",null,{"id":"old-way-2","children":[["$","a",null,{"href":"#old-way-2","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Old way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"createOrder"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$user"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$product"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$quantity"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token constant","children":"null"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$price"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//create order"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token function","children":"createOrder"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$user"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$product"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token constant","children":"null"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token number","children":"100"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]]}]}],["$","h4",null,{"id":"new-way-2","children":[["$","a",null,{"href":"#new-way-2","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"New way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"createOrder"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$user"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$product"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$quantity"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token constant","children":"null"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token variable","children":"$$price"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//create order"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token function","children":"createOrder"}],["$","span",null,{"className":"token punctuation","children":"("}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token argument-name","children":"user"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token variable","children":"$$user"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token argument-name","children":"product"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token variable","children":"$$product"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token argument-name","children":"price"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token number","children":"100"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]]}]}],["$","h2",null,{"id":"weak-maps","children":[["$","a",null,{"href":"#weak-maps","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Weak Maps"]}],["$","p",null,{"children":"A new data structure was added to PHP 8 called Weak Maps for objects that will get garbage collected when there's no more references to that object. This is a fantastic memory saving tool."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"protected"}]," ",["$","span",null,{"className":"token class-name type-declaration","children":"WeakMap"}]," ",["$","span",null,{"className":"token variable","children":"$$cache"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"get"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$key"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"return"}]," ",["$","span",null,{"className":"token keyword this","children":"$$this"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"cache"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token variable","children":"$$key"}],["$","span",null,{"className":"token punctuation","children":"]"}]," ",["$","span",null,{"className":"token operator","children":"??"}]," ",["$","span",null,{"className":"token constant","children":"null"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h2",null,{"id":"enums","children":[["$","a",null,{"href":"#enums","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Enums"]}],["$","p",null,{"children":"Enums provide a way to define a set of named values with corresponding constants. PHP 8 introduces native enums, allowing you to define your own enumerated types with fewer chances of errors."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"enum"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Status"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token keyword type-declaration","children":"int"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token constant","children":"DRAFT"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token number","children":"1"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token constant","children":"PUBLISHED"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token number","children":"2"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token constant","children":"ARCHIVED"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token number","children":"3"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//friendly display"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"display"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token keyword return-type","children":"string"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"return"}]," ",["$","span",null,{"className":"token keyword","children":"match"}]," ",["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword this","children":"$$this"}],["$","span",null,{"className":"token punctuation","children":")"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token scope","children":[["$","span",null,{"className":"token keyword","children":"self"}],["$","span",null,{"className":"token punctuation","children":"::"}]]}],["$","span",null,{"className":"token constant","children":"DRAFT"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Draft'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token scope","children":[["$","span",null,{"className":"token keyword","children":"self"}],["$","span",null,{"className":"token punctuation","children":"::"}]]}],["$","span",null,{"className":"token constant","children":"PUBLISHED"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Published'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token scope","children":[["$","span",null,{"className":"token keyword","children":"self"}],["$","span",null,{"className":"token punctuation","children":"::"}]]}],["$","span",null,{"className":"token constant","children":"ARCHIVED"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Archived'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h2",null,{"id":"typed-properties","children":[["$","a",null,{"href":"#typed-properties","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Typed Properties"]}],["$","p",null,{"children":"With PHP 7.4 came the ability to specify types for class properties, ensuring better code quality and eliminating potential errors. PHP 8 builds upon this feature to provide more concise syntax and additional read-only properties."}],["$","h4",null,{"id":"old-way-3","children":[["$","a",null,{"href":"#old-way-3","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Old way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword type-declaration","children":"string"}]," ",["$","span",null,{"className":"token variable","children":"$$title"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token class-name type-declaration","children":"DateTime"}]," ",["$","span",null,{"className":"token variable","children":"$$date"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"__construct"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword type-hint","children":"string"}]," ",["$","span",null,{"className":"token variable","children":"$$title"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token class-name type-declaration","children":"DateTime"}]," ",["$","span",null,{"className":"token variable","children":"$$date"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword this","children":"$$this"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"title"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$title"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword this","children":"$$this"}],["$","span",null,{"className":"token operator","children":"->"}],["$","span",null,{"className":"token property","children":"date"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token variable","children":"$$date"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h4",null,{"id":"new-way-3","children":[["$","a",null,{"href":"#new-way-3","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"New way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"__construct"}],["$","span",null,{"className":"token punctuation","children":"("}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword type-declaration","children":"string"}]," ",["$","span",null,{"className":"token variable","children":"$$title"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"readonly"}]," ",["$","span",null,{"className":"token class-name type-declaration","children":"DateTime"}]," ",["$","span",null,{"className":"token variable","children":"$$date"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h2",null,{"id":"match-statement-switch","children":[["$","a",null,{"href":"#match-statement-switch","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Match Statement (switch)"]}],["$","p",null,{"children":"The match statement is an enhanced version of the switch statement, providing more expressive syntax and making switch statements cleaner and more readable."}],["$","h4",null,{"id":"old-way-4","children":[["$","a",null,{"href":"#old-way-4","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Old way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"switch"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$status"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token number","children":"200"}],["$","span",null,{"className":"token punctuation","children":":"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token variable","children":"$$message"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'OK'"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"break"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token number","children":"300"}],["$","span",null,{"className":"token punctuation","children":":"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token variable","children":"$$message"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Multiple Choices'"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"break"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token number","children":"400"}],["$","span",null,{"className":"token punctuation","children":":"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token variable","children":"$$message"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Bad Request'"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"break"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"case"}]," ",["$","span",null,{"className":"token number","children":"500"}],["$","span",null,{"className":"token punctuation","children":":"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token variable","children":"$$message"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Internal Server Error'"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"break"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","h4",null,{"id":"new-way-4","children":[["$","a",null,{"href":"#new-way-4","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"New way:"]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token variable","children":"$$message"}]," ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token keyword","children":"match"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$status"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token number","children":"200"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'OK'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token number","children":"300"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Multiple Choices'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token number","children":"400"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Bad Request'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token number","children":"500"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Internal Server Error'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"default"}]," ",["$","span",null,{"className":"token operator","children":"=>"}]," ",["$","span",null,{"className":"token single-quoted-string string","children":"'Unknown Status'"}],["$","span",null,{"className":"token punctuation","children":","}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}]]}]}],["$","h2",null,{"id":"type-hints-and-type-declarations","children":[["$","a",null,{"href":"#type-hints-and-type-declarations","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Type Hints and Type Declarations"]}],["$","p",null,{"children":"Type hints and type declarations are a significant addition to PHP, enabling you to specify the expected parameter and return types for functions and methods. This enhances code clarity and offers better validation during development."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"setStatus"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token class-name type-declaration","children":"Status"}]," ",["$","span",null,{"className":"token variable","children":"$$status"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"//"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","p",null,{"children":"PHP 7 and PHP 8 have made significant strides in terms of type safety, allowing developers to add type hints to function arguments, return values, and class properties. This helps catch potential type-related errors during development and improves code reliability."}],["$","h2",null,{"id":"typed-arguments-and-return-types","children":[["$","a",null,{"href":"#typed-arguments-and-return-types","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Typed Arguments and Return Types"]}],["$","p",null,{"children":"In previous versions of PHP, function arguments and return types were not explicitly defined. However, PHP 7 introduced the ability to specify the expected types for function arguments and return values."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"add"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword type-hint","children":"int"}]," ",["$","span",null,{"className":"token variable","children":"$$a"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token keyword type-hint","children":"int"}]," ",["$","span",null,{"className":"token variable","children":"$$b"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token keyword return-type","children":"int"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"return"}]," ",["$","span",null,{"className":"token variable","children":"$$a"}]," ",["$","span",null,{"className":"token operator","children":"+"}]," ",["$","span",null,{"className":"token variable","children":"$$b"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","p",null,{"children":["In this example, the ",["$","code",null,{"children":"add"}]," function expects two integer arguments (",["$","code",null,{"children":"$$a"}]," and ",["$","code",null,{"children":"$$b"}],") and returns an integer."]}],["$","h2",null,{"id":"union-types","children":[["$","a",null,{"href":"#union-types","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Union Types"]}],["$","p",null,{"children":"PHP 8 introduced union types, which allow you to specify that a parameter or return value can be of more than one type. This is useful when a variable can hold different types of values."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"sum"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword type-declaration","children":"int"}],["$","span",null,{"className":"token operator","children":"|"}],["$","span",null,{"className":"token keyword type-declaration","children":"float"}]," ",["$","span",null,{"className":"token operator","children":"..."}],["$","span",null,{"className":"token variable","children":"$$numbers"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token keyword return-type","children":"int"}],["$","span",null,{"className":"token operator","children":"|"}],["$","span",null,{"className":"token keyword type-declaration","children":"float"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"return"}]," ",["$","span",null,{"className":"token function","children":"array_sum"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token variable","children":"$$numbers"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","p",null,{"children":["In this example, the ",["$","code",null,{"children":"sum"}]," function can accept either ",["$","code",null,{"children":"int"}]," or ",["$","code",null,{"children":"float"}]," values as variable arguments and can return either an ",["$","code",null,{"children":"int"}]," or ",["$","code",null,{"children":"float"}],"."]}],["$","h2",null,{"id":"intersection-types","children":[["$","a",null,{"href":"#intersection-types","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Intersection Types"]}],["$","p",null,{"children":"Intersection types, also introduced in PHP 8, allow you to specify that a parameter or return value must adhere to multiple types simultaneously. This is useful when you want to ensure that an object implements multiple interfaces, for example."}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"someMethod"}],["$","span",null,{"className":"token punctuation","children":"("}],"Foo ",["$","span",null,{"className":"token operator","children":"&"}]," ",["$","span",null,{"className":"token class-name type-declaration","children":"Bar"}]," ",["$","span",null,{"className":"token variable","children":"$$input"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token keyword return-type","children":"void"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// Code here"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","p",null,{"children":["In this example, the ",["$","code",null,{"children":"$$input"}]," parameter must be an object that implements both the ",["$","code",null,{"children":"Foo"}]," and ",["$","code",null,{"children":"Bar"}]," interfaces."]}],["$","h2",null,{"id":"nullable-types","children":[["$","a",null,{"href":"#nullable-types","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Nullable Types"]}],["$","p",null,{"children":["Nullable types allow you to specify that a parameter or return value can be either of a specified type or ",["$","code",null,{"children":"null"}],"."]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"setAge"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token operator","children":"?"}],["$","span",null,{"className":"token keyword type-hint","children":"int"}]," ",["$","span",null,{"className":"token variable","children":"$$age"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":":"}]," ",["$","span",null,{"className":"token keyword return-type","children":"void"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// Code here"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","p",null,{"children":["In this example, the ",["$","code",null,{"children":"setAge"}]," function expects an optional ",["$","code",null,{"children":"int"}]," parameter but also allows ",["$","code",null,{"children":"null"}]," values."]}],["$","h2",null,{"id":"readonly-properties","children":[["$","a",null,{"href":"#readonly-properties","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Readonly Properties"]}],["$","p",null,{"children":["PHP 8 introduced a new ",["$","code",null,{"children":"readonly"}]," modifier for class properties, allowing you to specify that a property can only be initialized once and cannot be modified after that."]}],["$","$L11",null,{"className":"language-php","children":["$","code",null,{"className":"language-php code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"class"}]," ",["$","span",null,{"className":"token class-name class-name-definition","children":"Foo"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"function"}]," ",["$","span",null,{"className":"token function function-definition","children":"__construct"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token keyword","children":"public"}]," ",["$","span",null,{"className":"token keyword","children":"readonly"}]," ",["$","span",null,{"className":"token keyword type-declaration","children":"string"}]," ",["$","span",null,{"className":"token variable","children":"$$name"}],["$","span",null,{"className":"token punctuation","children":")"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}]]}]}],["$","p",null,{"children":["In this example, the ",["$","code",null,{"children":"name"}]," property is marked as ",["$","code",null,{"children":"readonly"}],", indicating that it can only be assigned a value during object construction but cannot be modified later."]}],["$","h2",null,{"id":"performance-improvements","children":[["$","a",null,{"href":"#performance-improvements","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Performance Improvements"]}],["$","p",null,{"children":"One common misconception is that PHP is slow. However, PHP has undergone significant performance improvements in recent years, making it capable of handling most use cases efficiently."}],["$","p",null,{"children":"Between PHP 5.6 and PHP 7, there was nearly a 400% performance increase, and PHP 8 brought additional performance enhancements, improving speed by about 20%."}],["$","p",null,{"children":"While PHP might not be suitable for extremely high-performance scenarios with tens of thousands of requests per second, it is fast enough for the majority of web development needs. For specialized use cases with high-performance requirements, there are other specialized languages available."}],["$","h2",null,{"id":"conclusion","children":[["$","a",null,{"href":"#conclusion","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Conclusion"]}],["$","p",null,{"children":"PHP has evolved significantly since 2012, with the introduction of numerous features and improvements in PHP 5.4, PHP 7, and PHP 8. Traits, short array syntax, array destructuring, variadic functions, arrow functions, null coalescing operators, named arguments, and improved switch statements are just some of the many enhancements brought to the language. Additionally, PHP has seen improvements in type safety, allowing developers to create more reliable and robust code. With performance advancements, PHP is faster than ever before."}],["$","p",null,{"children":"Therefore, it is safe to say that PHP is not dead. It remains a popular and relevant programming language, constantly evolving to meet the demands of modern web development."}]]}]}],["$","div",null,{"className":"pb-6 pt-6 text-center text-gray-700 dark:text-gray-300","id":"comment","children":["$","$L12",null,{"slug":"php8-new-features-and-updates"}]}],["$","footer",null,{"children":["$","div",null,{"className":"flex flex-col text-sm font-medium sm:flex-row sm:justify-between sm:text-base","children":[["$","div",null,{"className":"pt-4 xl:pt-8","children":["$","$L9",null,{"href":"/blog/set-up-development-environment-in-ubuntu-22-04-lamp-and-more","className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","aria-label":"Previous post: Set Up Development Environment in Ubuntu 22.04 - LAMP and More","children":["← ","Set Up Development Environment in Ubuntu 22.04 - LAMP and More"]}]}],"$undefined"]}]}]]}]]}]}]]}]]