TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

PHP

PHP If Statement

Overview

We can use PHP If Statement to execute code statements based on condition(s). This statement is also called a conditional statement. We can make decisions and execute code only when the conditions are met.

Syntax

Let’s see a simple syntax of the statement.

if(condition)
{
// PHP Statements;
}

The PHP code in the if block will be executed when the condition is met i.e evaluates to true.

Example


<!DOCTYPE html>
<!–
PHP If Statement Demo
–>
<html>
<head>
<meta charset=”UTF-8″>
<title>PHP If Block</title>
</head>
<body>
<h1> PHP If Block </h1>
<?php
//PHP If Block
$a = 120;
$b = 30;
if($a > $b)
{
//This block will execute only if a > b
echo “a= $a”;echo “<br/>”;
echo “b= $b”;echo “<br/>”;
echo “a is greater than b”;
}
?>
<br/>
<h1>PHP Tutorials </h1>
<h3>www.TestingDocs.com</h3>
</body>
</html>


 

—

PHP Tutorials

PHP Tutorials on this website:

https://www.testingdocs.com/php-tutorials/

More Information on PHP

https://www.php.net/

Related Posts

Compoer Command line command

PHP /

Install Slim Framework on Windows

php download website

PHP /

Download and Install PHP on Windows

Composer Install Windows

PHP /

Composer Download on Windows

Apache conf file

PHP /

PHP 7 Configuration in Apache Server

testing php linux

PHP /

Testing PHP with Apache Server on Linux

‹ PHP Arithmetic Operators› IDE for PHP development

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version