I'm checking whether to enter an if statement and debugging the result of a function it turn out that it returns null as a string.
In my code I'm checking:
<?php if($_product->getData('attr1') || $_product->getData('attr2')): ?>
Do stuf here
<?php endif; ?>
And 'attr2' returns 'null', a string with length equals to 4.
How can I check if the variable is null for real?
getData()returns'null'instead ofnull? Handle it there.'null'. IMO the proper way to handle this is to fix getData method to returnnull. It will ease your pain in all places where you use it then. Because what ifattr2has really a'null'value?'null'value.