Answers for "if shorthand"

PHP
3

shorthand if php

$is_admin = ($user['permissions'] == 'admin') ? true : false;
Posted by: Guest on May-15-2020
2

php if short form

<?php echo ($qte > 0) ? $qte : 0; ?>
Posted by: Guest on November-14-2020
0

if and else shorthand

//Long version  
let points = 70;   
let result;   
if(marks >= 50){  
    result = 'Pass';   
}else{  
    result = 'Fail';   
}

//Shorthand  
let points = 70;   
let result = marks >= 50 ? 'Pass' : 'Fail';
Posted by: Guest on April-27-2021

Browse Popular Code Answers by Language