Name : Fu’ad Mohamed Abdirahman ID: 12609
Chapter (1) ( Answers)
1. PHP is a server-side programming language used to create web
pages that run dynamically on the server before being sent to the
client.
2. - OpenSource: PHP is free to use and distribute, making it highly
accessible for developers.
- Cross-Platform Compatibility: PHP runs on multiple
platforms, including Windows, Linux, and OS.
- Embedded in HTML: PHP can be embedded directly into HTML,
allowing developers to mix PHP code with static HTML content
easily.
3. PHP: Runs on the server before sending the output (usually
HTML) to the browser.
- JavaScript: Runs on the client’s browser after the page has
loaded.
4. PHP supports a wide range of databases, including MySQL,
PostgreSQL, Oracle, and Microsoft SQL Server
5. PHP handles form data using the $_GET, $_POST, and
$_REQUEST superglobal arrays.
6. PHP stand for Hypertext Preprocessor.
7. PHP is a Hight Level Language.
8. <html>
<head>
<title> Assignment </title>
</head>
<body>
<?php>
echo “ Hello, PHP!”;
?>
</body>
</html>
9. The default file extension for PHP files is .php.
10. ???
Subject: PHP | Lecturer: Abdikarim Ibrahim Mohamed
Name : Fu’ad Mohamed Abdirahman ID: 12609
Chapter (2) ( Answers)
1. A variable in PHP is a container used to store data, such as numbers, text, or arrays.
<?php
$name ="John"; // String variable
$age = 25; // Integer variable The output of example
$price = 19.99; // Float variable
Name: John
echo "Name: " . $name . “<br>";
echo "Age: " . $age . “<br>"; Age: 25
echo "Price: $" . $price;
Price: $19.99
?>
2. The echo statement is the most common
way to output text in PHP.
- The print statement works similarly to echo, but it can only output one argument
and always returns 1, making it slightly slower than echo.
3. Using the define() function (Traditional way)
- Using the const keyword (Newer way, since PHP 5.3)
4. The Main data types in PHP are:
A string is a sequence of letters, numbers, special characters and arithmetic values
or combination of all.
An integer is a whole number (positive or negative) without a decimal point.
Afloat (also called a double) is a number with a decimal point.
A Boolean represents true (true) or false (false).
5. the ++ operator is the increment operator, which increases a variable's value by
1. It can be used in two ways:
- Pre-Increment (++$var) and Post-Increment ($var++).
6. <?php
$age = 25;
echo "My age is " . $age;
?>
7. <?php
$num1 = 10;
$num2 = 5;
$addition = $num1 + $num2;
$subtraction = $num1 - $num2;
$multiplication = $num1 * $num2;
$division = $num1 / $num2;
echo "Addition: $num1 + $num2 = $addition <br>";
echo "Subtraction: $num1 - $num2 = $subtraction <br>";
echo "Multiplication: $num1 * $num2 = $multiplication <br>";
echo "Division: $num1 / $num2 = $division <br>";
?>
Subject: PHP | Lecturer: Abdikarim Ibrahim Mohamed