
- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Environment Setup
- PHP - Syntax Overview
- PHP - Variable Types
- PHP - Constants
- PHP - Operator Types
- PHP - Decision Making
- PHP - Loop Types
- PHP - Arrays
- PHP - Strings
- PHP - Web Concepts
- PHP - GET & POST
- PHP - File Inclusion
- PHP - Files & I/O
- PHP - Functions
- PHP - Cookies
- PHP - Sessions
- PHP - Sending Emails
- PHP - File Uploading
- PHP - Coding Standard
- Advanced PHP
- PHP - Predefined Variables
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Bugs Debugging
- PHP - Date & Time
- PHP & MySQL
- PHP & AJAX
- PHP & XML
- PHP - Object Oriented
- PHP - For C Developers
- PHP - For PERL Developers
- PHP Form Examples
- PHP - Form Introduction
- PHP - Validation Example
- PHP - Complete Form
- PHP login Examples
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP AJAX Examples
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML Example
- PHP - XML Introduction
- PHP - Simple XML
- PHP - Simple XML GET
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Frame Works
- PHP - Frame Works
- PHP - Core PHP vs Frame Works
- PHP Design Patterns
- PHP - Design Patterns
- PHP Function Reference
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP - Comparison Operators Example
Try following example to understand all the comparison operators. Copy and paste following PHP program in test.php file and keep it in your PHP Server's document root and browse it using any browser.
<html> <head> <title>Comparison Operators</title> </head> <body> <?php $a = 42; $b = 20; if( $a == $b ) { echo "TEST1 : a is equal to b<br/>"; }else { echo "TEST1 : a is not equal to b<br/>"; } if( $a > $b ) { echo "TEST2 : a is greater than b<br/>"; }else { echo "TEST2 : a is not greater than b<br/>"; } if( $a < $b ) { echo "TEST3 : a is less than b<br/>"; }else { echo "TEST3 : a is not less than b<br/>"; } if( $a != $b ) { echo "TEST4 : a is not equal to b<br/>"; }else { echo "TEST4 : a is equal to b<br/>"; } if( $a >= $b ) { echo "TEST5 : a is either greater than or equal to b<br/>"; }else { echo "TEST5 : a is neither greater than nor equal to b<br/>"; } if( $a <= $b ) { echo "TEST6 : a is either less than or equal to b<br/>"; }else { echo "TEST6 : a is neither less than nor equal to b<br/>"; } ?> </body> </html>
This will produce the following result −
TEST1 : a is not equal to b TEST2 : a is greater than b TEST3 : a is not less than b TEST4 : a is not equal to b TEST5 : a is either greater than or equal to b TEST6 : a is neither less than nor equal to b
php_operator_types.htm
Advertisements