Home
PHP
Chart
Class
Components
Cookie Session
Data Structure
Data Type
Date
Design Patterns
Development
DNS
Email
File Directory
Form
Functions
Graphics Image
HTML
Language Basics
Login Authentication
Math
MySQL Database
Network
Operator
PDF
Reflection
Statement
String
Utility Function
Web Services SOAP WSDL
XML
The Ternary Operator : Comparison Operators « Operator « PHP
PHP
Operator
Comparison Operators
The Ternary Operator
<? $age = 18; $agestr = ($age < 16) ?
'child'
:
'adult'
; ?>
Related examples in the same category
1.
Comparison Operators
2.
Comparing numbers and strings
3.
Loose Comparison Operators
4.
Using Comparison Operators in if Statements
5.
The equality operator
6.
These values are compared using dictionary order
7.
These values are compared using numeric order
8.
Equality Operators summary table
9.
Equality Operators in action