English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Explain if else statement in PHP. With an example.

Advertisements
Advertisements

Question

Explain if else statement in PHP. With an example.

Answer in Brief
Advertisements

Solution

If a statement executes a statement or a group of statements if a specific condition is satisfied by the user expectation. When the condition gets false (fail) the else block is executed.

Syntax:

if (condition)
{
Execute statement(s) if condition is true;
} else
{
Execute statement(s) if condition is false;
}

Example:

<?php
$Pass_Mark=35;
$Student_Mark=70;
if ($Student_Mark>= $Pass_Mark)
{
echo “The Student is eligible for the promotion”;
}
else
{
echo “The Student is not eligible for the promotion”; }
?>
shaalaa.com
Control structures in PHP
  Is there an error in this question or solution?
Chapter 6: PHP Conditional Statements - Evaluation - PART – IV [Page 111]

APPEARS IN

Samacheer Kalvi Computer Applications [English] Class 12 TN Board
Chapter 6 PHP Conditional Statements
Evaluation - PART – IV | Q 5. | Page 111
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×