<?php
$marks = 75;
if ($marks >= 50) {
echo "You passed!";
} else {
echo "You failed!";
}
?>
Explanation:
- If condition is true, “You passed!” will be printed.
- Otherwise, “You failed!” is shown.
<?php
$marks = 75;
if ($marks >= 50) {
echo "You passed!";
} else {
echo "You failed!";
}
?>
Explanation:
<?php
$number = 100; // Integer
$price = 99.99; // Float
$name = "PHP"; // String
$is_active = true; // Boolean
?>
Explanation:
PHP supports int, float, string, boolean, array, object, null types.
<?php
$name = "Saim";
$age = 25;
echo "My name is $name and I am $age years old.";
?>
Explanation:
$
.My name is Saim and I am 25 years old.
<?php
echo "Hello, World!";
?>
Explanation:
<?php ... ?>
is used to write PHP code.echo
outputs text to the browser.