This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 4 years ago.
what is the meaning of '??' operator in php?
I've seen someone using it like this. I've searched many results in google. But didn't found any solution.
$this->variable = $arg['value'] ?? NULL
?? is the new (since PHP 7) NULL coalescing operator. If the first argument is set and is not null it is returned, otherwise, the second argument is returned.
Related
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
What does "===" mean? [duplicate]
(10 answers)
Closed 3 years ago.
I saw the line below in a class method :
return $return === 1;
What's the meaning of this ? As "===" is a comparaison operator, what would be the expected behavior of using this operator directly in a return ? Return only if 1 ?
Thanks
This question already has answers here:
# symbol before php function [duplicate]
(3 answers)
What is the use of the # symbol in PHP?
(11 answers)
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 4 years ago.
can you please help i just want to know why we use #in_array function.
$name = array("ravi", "ram", "rani", 87);
if (in_array("ravi", $name, TRUE)){
}
if (#in_array("ravi", $name, TRUE)){
}
The "#" symbol turn off the errors. It is not a good idea to use it.
PHP Error Control Operators
PHP supports one error control operator:
the at sign (#
http://php.net/manual/en/language.operators.errorcontrol.php
This question already has answers here:
PHP short-ternary ("Elvis") operator vs null coalescing operator
(15 answers)
Closed 4 years ago.
I have this kind of test again, and again, and I feel like there is a more elegant way to do it.
(isset($country['capital'])) ? $country['capital'] : null
Can you help me?
You can use or Operator In Laravel Blade template
$country['capital'] or null
And In php 7 you can use Null coalescing operator
$country['capital'] ?? null
From PHP docs
The null coalescing operator (??) has been added as syntactic sugar
for the common case of needing to use a ternary in conjunction with
isset(). It returns its first operand if it exists and is not NULL;
otherwise it returns its second operand.
Since PHP 7 you can do
$country['capital'] ?? null;
This question already has answers here:
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
(24 answers)
Closed 5 years ago.
I've seen this code and I don`'t know what does it mean
$page = $_GET['page'] ?? 'home';
Can somebody tell me its meaning?
It's null coalesce operator.
It will return $_GET['page'] unless it's null. In case it's null it would return default value 'home'.
It has same meaning as:
!is_null($_GET['page']) ? $_GET['page'] : 'home'
This question already has answers here:
What is the "->" PHP operator called? [closed]
(15 answers)
Closed 9 years ago.
i am php programmer but i don't know name of this operator
->
this operator use in OOP in php.
for example
$this->get();
It is the object operator (known as T_OBJECT_OPERATOR internally).
The official name is object operator : T_OBJECT_OPERATOR.
Generally called " arrow ".