About PHP Programming Language

Overview

PHP is a server-side scripting language primarily used for web development. It can generate dynamic page content, interact with databases, handle forms, and more.

Example: Hello World

Here's a basic "Hello, World!" program in PHP:

<?php
  echo "Hello, World!";
?>

Variables and Operations

PHP supports variables and operations similarly to other languages:

<?php
$a = 10;
$b = 5;
$sum = $a + $b;
$product = $a * $b;

echo "Sum: $sum";
echo "Product: $product";
?>

Conditional Statements

Using conditional statements in PHP:

<?php
$number = 10;

if ($number > 0) {
    echo "The number is positive.";
} else {
    echo "The number is not positive.";
}
?>

Loops

Example of a loop in PHP:

<?php
for ($i = 1; $i <= 5; $i++) {
    echo "Number: $i <br>";
}
?>