php - Whats the difference between ? : and || -
php - Whats the difference between ? : and || -
what difference there between using ?: conditional operator , || logical or.
i finding code works with:
$screenpixelratio = !empty($_cookie['screenpixelratio']) || $_cookie['screenpixelratio'] || $fallback_pixelratio; but not:
$screenpixelratio = !empty($_cookie['screenpixelratio']) ? $_cookie['screenpixelratio'] : $fallback_pixelratio; could please explain why work one, not other.
|| binary operators operators deal 2 arguments
as says check first if true not gonna check farther else check farther
?: ternary operator operator takes 3 arguments. arguments , result can of different types.
expression1 ? expression2 : expression3; php
Comments
Post a Comment