Home >> PHP >> Ternary operator in PHP

Ternary operator in PHP

It is similar to conditional statement.

Syntax

Condition?true:false

Example

In if /else

if(10>5){

      echo 'Bigger';

}else{

echo 'Smaller';

}

Output

Bigger

In turnory operator

echo (10>5?'Bigger':'Smaller');

Output

Bigger

Post Your Comment

Next Questions
Variable types
What is password encrypt and decrypt function
Difference between echo and print
How can destroy and unset the variable of a session
Function
isset() function
unset() function
empty() function
What are function for controlling script execution
exit() function
die() function
fun_num_args() function
ereg_replace() function
ereg_ireplace() function
preg_match() function
preg_replace() function
File handling
fopen() function
fclose() function
fread() function
create the file
Check the file is available or not
Destroy the file
Write into the file
Create into folder

Copyright ©2022 coderraj.com. All Rights Reserved.