Nullable return types in PHP7

PHP 7 introduces return type declarations. Which means I can now indicate the return value is a certain class, interface, array, callable or one of the newly hintable scalar types, as is possible for function parameters. function returnHello(): string { return ‘hello’; } Often it happens that a value is not always present, and that … Read more

What is (the ‘Spaceship’ Operator) in PHP 7? [duplicate]

This question already has answers here: Reference — What does this symbol mean in PHP? (23 answers) Closed 6 years ago. PHP 7, which will come out in November this year will introduce the Spaceship (<=>) operator. What is it and how does it work? This question already has an answer in our general reference … Read more

PHP7 : install ext-dom issue

I’m running laravel 5.4 on Ubuntu 16.04 server with PHP7. trying to install cviebrock/eloquent-sluggable package throw some error: pish@let:/home/sherk/ftp/www$ sudo composer require cviebrock/eloquent-sluggable Do not run Composer as root/super user! See https://getcomposer.org/root for details Using version ^4.2 for cviebrock/eloquent-sluggable ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements … Read more

PHP ternary operator vs null coalescing operator

Can someone explain the differences between ternary operator shorthand (?:) and null coalescing operator (??) in PHP? When do they behave differently and when in the same way (if that even happens)? $a ?: $b VS. $a ?? $b 14 s 14 When your first argument is null, they’re basically the same except that the … Read more