Jump to content

( ? : ) syntax


sycosyco123

Recommended Posts


<?php
$show1=1;
($show1==1)?'show1':'show0'; // if $show1 = 1 than print show1, else print show0
$show1=0; 
print ($show1==1)?'show1':'show0';

?>

SIMILIAR TO THIS:

<?php
$show1=1;
if (!$show1 == 1) 
    print 'show1';
else
    print 'show0';
?>

 

It is just an if/else statement written really short. I forget what they call it but is good for  variable declarations etcc.

Link to comment
https://forums.phpfreaks.com/topic/46493-syntax/#findComment-226189
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.