Created
October 6, 2022 08:35
-
-
Save trych/1b469a43cfe22cd29546155b168d94b5 to your computer and use it in GitHub Desktop.
Null error issue in argument expressions of e()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$poster = $video->poster()->toFile(); | |
// das geht nicht, wenn $poster null ist, *obwohl* die var $poster existiert | |
// Call to a member function resize() on null | |
e($poster, Html::attr('poster', $poster->resize(1280)->url())); | |
// das hingegen funktioniert: | |
if($poster) echo Html::attr('poster', $poster->resize(1280)->url()); | |
// und das hier funktioniert auch | |
echo $poster ? Html::attr('poster', $poster->resize(1280)->url()) : ''; | |
// was auch funktioniert ist der nullsafe operator | |
e($poster, Html::attr('poster', $poster?->resize(1280)->url())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment