10..Assignment.php
10..Assignment.php
Assignment :
1. What is PHP, and why is it used?
PHP (Hypertext Preprocessor) is a server-side scripting language designed for web
development. It is used to create dynamic web pages, manage databases, handle form
submissions, and build web applications.
2. Describe three key features of PHP.
o Server-side execution: PHP code runs on the server,
generating HTML sent to the client.
o Database integration: PHP supports multiple databases like
MySQL, PostgreSQL, and SQLite.
o Cross-platform compatibility: PHP runs on various
operating systems, including Windows, macOS, and Linux.
3. How does PHP differ from client-side scripting languages like JavaScript?
o PHP executes on the server, whereas JavaScript runs in the
user's browser.
o PHP can interact directly with databases, while JavaScript
requires AJAX or other technologies to do so.
o PHP generates dynamic HTML before the page is sent to the
browser, while JavaScript manipulates the page after it loads.
4. What are some popular databases that PHP supports?
PHP supports MySQL, PostgreSQL, SQLite, Oracle, Microsoft SQL Server, and
MariaDB.
5. Explain how PHP handles form data.
PHP collects form data using $_GET and $_POST superglobal arrays. Example:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
echo "Hello, " . htmlspecialchars($name);
}
?>
6. What does PHP stand for?
PHP originally stood for "Personal Home Page" but now stands for "PHP: Hypertext
Preprocessor" (a recursive acronym).
7. Which type of language is PHP?
PHP is a server-side scripting language primarily used for web development.
8. Create a new PHP file (test.php) and write a script that displays "Hello, PHP!".
<?php
echo "Hello, PHP!";
?>
9. What is the default file extension for PHP files?
The default file extension for PHP files is .php.
10. Which of the following is a characteristic of PHP?
PHP is open-source, server-side, interpreted, and supports embedding within
HTML.