Home »
Aptitude Questions and Answers »
PHP Aptitude Questions and Answers
PHP Basics Aptitude Questions and Answers
PHP Basics Aptitude Questions and Answers: This section contains aptitude questions and answers on PHP Basics.
By Nidhi Last updated : December 15, 2023
This section contains Aptitude Questions and Answers on PHP Basics.
1) There are the following statements that are given below, which of them are correct PHP?
- PHP stands for the Preprocessor Home page.
- PHP is a scripting language.
- PHP is a client-side hypertext language.
- PHP is used to make dynamic and interactive pages.
Options:
- A and C
- B and D
- A, B, and C
- A, B, C, and D
2) PHP stands for?
- Preprocessor Home Page
- Personal Home Page
- Hypertext Preprocessor
- Preprocessor Hypertext Page
Options:
- A and B
- A and C
- B and C
- C and D
Correct answer: 3
B and C
Previously PHP stands for "Personal Home Page" and now, it is called "Hypertext Preprocessor".
3) Can we create a web-service in PHP?
- Yes
- No
Correct answer: 1
Yes
Yes, we can create a web-service in PHP.
4) What is the extension is used for PHP scripting files?
- .php
- .ph
- .p
- .phtml
Correct answer: 1
.php
The .php extension is used for PHP scripting files.
5) Can we generate an executable file after the compilation of PHP code?
- Yes
- No
Correct answer: 2
No
No, PHP is a scripting language so that we can generate an executable file.
6) Which of the following are popular frameworks used in PHP?
- CakePHP
- FuelPHP
- Zend
- Yii
Options:
- A and B
- C and D
- A, B, and C
- A, B, C, and D
Correct answer: 4
A, B, C, and D
All given options are popular frameworks used in PHP.
7) A PHP file can contain?
- HTML code
- Windows Application code
- Java-script code
- PHP code
Options:
- A and B
- A, B, and C
- A, C, and D
- A, B, C, and D
Correct answer: 3
A, C, and D
A PHP file can contain HTML, JavaScript, and PHP code.
8) Which of the following can be dmpageTU by PHP code?
- Creation of dynamic WebPages.
- Add, delete, and modify data in the database.
- Encryption and decryption of data.
- PHP can send and receive cookies.
Options:
- A and B
- C and D
- A, B, and C
- A, B, C, and D
Correct answer: 4
A, B, C, and D
All given tasks can be performed by the PHP code.
9) PHP supports AJAX?
- Yes
- No
Correct answer: 1
Yes
Yes, PHP supports AJAX.
10) Which of the following operating systems can run PHP scripts?
- MAC OS X
- Windows
- Linux
- Unix
Options:
- A and B
- C and D
- A, B, and C
- A, B, C, and D
11) Which of the following web-server is used for PHP scripts?
- Tomcat
- IIS
- Apache
- Cassini
Correct answer: 3
Apache
The Apache web-server is used for PHP scripts.
12) Which of the following are software bundle is used for PHP and its related software's?
- LAMP
- WAMP
- LANP
- MAMP
Options:
- A and B
- C and D
- A, B, and D
- B, C, and D
Correct answer: 3
A, B, and D
The LAMP, WAMP, and MAMP software bundle are used for installing PHP and related software.
13) What is 'M' stands for in LAMP?
- Markup
- MySQL
- Most
- Microsoft
Correct answer: 2
MySQL
The "M" stands for MySQL in LAMP. LAMP is a software bundle to install PHP, MySQL on the Linux operating system.
14) What the full form of 'P' can be in the WAMP?
- PHP
- Python
- Perl
- All of the above
Correct answer: 4
All of the above
The full form of "P" can be PHP, Python, and Perl in the WAMP.
15) Can we place a PHP script anywhere in the ".php" file?
- Yes
- No
Correct answer: 1
Yes
Yes, we can place the PHP script anywhere in the ".php" file.
16) Which of the following functions are used to print text on the webpage?
- print
- echo
- disp
- disptext
Options:
- Only A
- Only B
- A and B
- C and D
17) What is the correct output of the given code snippets in PHP?
<?php
$NUM1 = 5;
$NUM2 = 10;
$Sum = $NUM1 + $NUM2;
print "Sum is: " + $Sum;
?>
- Sum is: 15
- Print '15' with a warning
- Syntax error
- NmpageTU of the above
Correct answer: 2
Print '15' with a warning
The above code will print "15" with a warning.
15
PHP Warning: A non-numeric value encountered in /home/example1.php on line 9
18) What is the correct output of the given code snippets in PHP?
<?php
$NUM1 = 5;
$NUM2 = 10;
$Sum = $NUM1 + $NUM2;
print "Sum is: " . $Sum;
?>
- Sum is: 15
- Print '15' with a warning
- Syntax error
- NmpageTU of the above
Correct answer: 1
Sum is: 15
The above code will print the 'Sum is: 15' on the webpage.
19) PHP is a case sensitive language for inbuilt functions?
- Yes
- No
Correct answer: 2
No
No, PHP is not a case sensitive language for inbuilt functions.
20) What is the correct output of the given code snippets in PHP?
<?php
echo "<b>" . "Hello World" . "</b>";
?>
- Print "<b>Hello World</b>" on the webpage.
- Print "Hello World" in bold style on the webpage.
- Print "Hello World" without bold style on the webpage.
- NmpageTU of the above
Correct answer: 2
Print "Hello World" in bold style on the webpage.
The above code will print "Hello World" in bold style on the webpage.
21) Which of the following ways are used to comment a single line in PHP?
- # commented line
- // commented line
- 'commented line
- : commented line
Options:
- Only A
- Only B
- A and B
- C and D
Correct answer: 3
A and B
Options A and B are used to comment a single line in PHP code.
Learn: PHP Comments
22) What is the correct output of the given code snippets in PHP?
<?php
$NUM1 = 5;
$NUM2 = 10;
$Sum = $NUM1 /*5+10=15*/ + $NUM2;
print "Sum is: " . $Sum;
?>
- Sum is: 15
- Print "15" with warning
- Syntax error
- NmpageTU of the above
Correct answer: 1
Sum is: 15
The above code will print the "Sum is: 15" on the webpage.
23) What is the correct output of the given code snippets in PHP?
<?php
int $NUM1=5;
int $NUM2=10;
$Sum =$NUM1 /*5+10=15*/+ $NUM2;
print "Sum is: ".$Sum;
?>
- Sum is: 15
- Print "15" with warning
- Syntax error
- NmpageTU of the above
Correct answer: 3
Syntax error
The above code will generate a syntax error.
24) What is the correct output of the given code snippets in PHP?
<?php
$NUM1=5;
$NUM2=10;
$Sum =$NUM1 + $NUM2;
print "Sum is: ".$sum;
?>
- Sum is: 15
- Syntax error
- Sum is:
- NmpageTU of the above
Correct answer: 3
Sum is:
The above code will print "Sum is:" on the webpage because variable names are case-sensitive in PHP language.
25) What is the correct output of the given code snippets in PHP?
<?php
$NUM1=5;
$NUM2=10;
$Sum =$NUM1 + $NUM2;
print "Sum is: $Sum";
?>
- Sum is: 15
- Syntax error
- Sum is:
- NmpageTU of the above
Correct answer: 1
Sum is: 15
The above code will print the "Sum is: 15" on the webpage.
26) Is it true the "echo" statement has no return value while "print" has return value?
- Yes
- No
Correct answer: 1
Yes
Yes, the given statement is true.