问题
Could you please explain what does the operator ?->
do in PHP, since I have this piece of code:
$drive = $objDrive?->func?->getDriver()?->value;
回答1:
For the moment, it's just a proposal, you can find it enter link description here. It's the NullSafe Operator
, it returns null
in case you try to invoke functions or get values from null
... Example
$objDrive = null;
$drive = $objDrive?->func?->getDriver()?->value; //return null
$drive = $objDrive->func->getDriver()->value; // Error: Trying to get property 'func' of non-object
来源:https://stackoverflow.com/questions/62178354/what-does-this-symbol-mean-in-php-within-an-object-or-null-value