Sharpen your PHP skills with these multiple choice questions on PHP basics. Great for beginners, students, and interview preparation. Start practicing now!.
<?php
echo "Hello ";
echo "World!";
?>
Hello World!
The `echo` statement is used to output the text. In this case, "Hello" and "World!" are printed sequentially without any issues.
<?php
$x = 5;
$y = 10;
echo $x + $y;
?>
15
The `+` operator is used to add two numbers. In this case, the sum of `$x` and `$y` (5 + 10) results in 15.
<?php
$a = 10;
$b = 5;
$a = $a / $b;
echo $a;
?>
Which component in XAMPP is used to serve web pages? A. MySQL B. Apache C. FileZilla D. Mercury ✅ Answer: B. Apache
What is the default folder in XAMPP to save your website files? A. /htdocs B. /public_html C. /www D. /webroot ✅ Answer: A. /htdocs
What is the default port number for Apache in XAMPP? A. 21 B. 80 C. 3306 D. 443 ✅ Answer: B. 80
Which component of XAMPP is used to manage databases? A. Apache B. phpMyAdmin C. FileZilla D. Tomcat ✅ Answer: B. phpMyAdmin
Which file extension is used for PHP files saved in XAMPP? A. .html B. .php C. .js D. .exe ✅ Answer: B. .php
Which of the following is a client-side scripting language? A. PHP B. JavaScript C. Python D. ASP.NET ✅ Answer: B. JavaScript
Which scripting language runs on the server and generates dynamic content before sending it to the browser? A. HTML B. CSS C. PHP D. JavaScript ✅ Answer: C. PHP
What is the main purpose of client-side scripting? A. To store data in a database B. To control the web server C. To handle user interface interactions D. To validate server responses ✅ Answer: C. To handle user interface interactions
Which scripting runs after the webpage is loaded in the browser? A. Server-side B. Client-side C. Both D. Neither ✅ Answer: B. Client-side
What is a common use of server-side scripting? A. Creating animations B. Interacting with the database C. Changing the font style D. Adjusting layout with CSS ✅ Answer: B. Interacting with the database
Which combination is commonly used in full-stack web development? A. HTML and Excel B. JavaScript (client) and PHP (server) C. PHP (client) and HTML (server) D. CSS (client) and MySQL (client) ✅ Answer: B. JavaScript (client) and PHP (server)
Match the scripting language with its appropriate category:
Language | Type |
---|---|
A. JavaScript | 1. Server-side |
B. PHP | 2. Client-side |
C. Python | |
D. HTML | |
E. CSS |
Correct Answers: