I have this code:
function getBlockName($blockId){
$block = classContent::findById(conn(), $blockId);
echo $block->getBname();
}
now if the function outputs something works fine, if it doesn’t output anything I have the
Fatal error: Call to a member function getBname() on a non-object in...
I’m pretty new to php so I couldn’t find a solution on how to handle the error.
Any help would be very much appreciated! 🙂
Mauro
Most likely it doesn’t return an object if nothing was found.
Edit: recommendation from comment.