+ 2
What is the different of this code?
the second and third code, its new to me. i just learned it couple days ago. can anyone explain the different or it just the shorthand of first code? which better by the way, or there is to another way to prevent undefined variables without declare separately. https://code.sololearn.com/w6jRoZKJUnp3/?ref=app
2 Respostas
+ 4
Second is the Null coalescing operator. It was added in PHP 7. If the value to the left of ?? is Null it will return the value to the right.
http://php.net/manual/en/migration70.new-features.php
scroll down to the section.
Third is the ternary operator. If the expression before ? evaluates to true then the code between the ? and : is ran and its value is returned otherwise if false the code after the : is ran and its value is returned. It is very similar to an if else block.
+ 1
waw...
thanks for your answer...