How to Use If Statements in PHP – Coding Cyber

How to Use If Statements in PHP

How to Use If Statements in PHP

Other Articles in PHP Logical Statements Section

Quickly Navigate to Other Sections in PHP Tutorials

PHP Basics
PHP Data Types
PHP Advanced Data Types
PHP Logical Statements
PHP Operators
PHP Loops
User Defined Functions in PHP
Useful PHP Functions

Conditional Statements in PHP are used to check the conditions between two statements, if the condition is true then given statement will be executed. Otherwise, the next statement will be executed.

Syntax of if statement
If the condition is true, then the below statement will be executed.

Statements to be executed

Example code for if statement

Here, we have assigned $a as value 5. And checking that if $a value is greater than two or not. Because the statement is true, following statement will be executed.

$a = 5;
if($a > 2){
echo "a number is greater than 2";
Vivek Vengala

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: