First, let’s look at a simple example now:
Copy the code The code is as follows:
$a = 2;
($a == 1) ? $test = "Enterprise" : $test = "Region";#Writing method 1
echo $test;
?>
In the above example, first determine whether $a is 1. If the string "enterprise" is stored in the $test variable and then output, if not the string "region" is stored in the $test variable and then output. ;
The appeal example code is equivalent to:
Copy code The code is as follows:
$a = 2;
#Writing method 2
$test = ($a == 1) ? "Enterprise" : "Region";
#Writing method three
if($a == 1){
$test="enterprise";
}else{
$test="region";
}
echo $test;
?>
http://www.bkjia.com/PHPjc/769238.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/769238.htmlTechArticleFirst, let’s look at a simple example now: Copy the code as follows: ?php $a = 2; ($ a == 1) ? $test = "Enterprise" : $test = "Region";#Writing method 1 echo $test; ? As for the above example, first...