diff options
author | Marcel Ribeiro Dantas <ribeirodantasdm@gmail.com> | 2022-06-27 00:28:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-27 00:28:16 +0200 |
commit | 5d133e847846b4c8d436f7a567674c2e1df35a13 (patch) | |
tree | 7ebc7704f02ceef195a8896a80a06ed81cc12585 /php.html.markdown | |
parent | 27f7f03401ff747a61a912fdf73549b1788b13e1 (diff) | |
parent | 8f28c8021b8ce3cb791861ad19c41e12228d8bcd (diff) |
Merge branch 'master' into patch-1
Diffstat (limited to 'php.html.markdown')
-rw-r--r-- | php.html.markdown | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/php.html.markdown b/php.html.markdown index 57ba29c4..821bde8f 100644 --- a/php.html.markdown +++ b/php.html.markdown @@ -591,6 +591,12 @@ echo $my_class->property; // => "public" echo $my_class->instanceProp; // => "An instance property" $my_class->myMethod(); // => "MyClass" +// Nullsafe operators since PHP 8 +// You can use this when you're unsure if the abstraction of $my_class contains has a property/method +// it can be used in conjunction with the nullish coalesce operator to ensure proper value +echo $my_class->invalid_property // An error is thrown +echo $my_class?->invalid_property // => NULL +echo $my_class?->invalid_property ?? "public" // => "public" // Extend classes using "extends" class MyOtherClass extends MyClass |