PHP Tutorial

PHP Examples

PHP Practice

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?
  1. PHP stands for the Preprocessor Home page.
  2. PHP is a scripting language.
  3. PHP is a client-side hypertext language.
  4. PHP is used to make dynamic and interactive pages.

Options:

  1. A and C
  2. B and D
  3. A, B, and C
  4. A, B, C, and D

Correct answer: 2
B and D

Statements B and D are correct about PHP.

Learn: What is PHP programming?


2) PHP stands for?
  1. Preprocessor Home Page
  2. Personal Home Page
  3. Hypertext Preprocessor
  4. Preprocessor Hypertext Page

Options:

  1. A and B
  2. A and C
  3. B and C
  4. 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?
  1. Yes
  2. 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?
  1. .php
  2. .ph
  3. .p
  4. .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?
  1. Yes
  2. 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?
  1. CakePHP
  2. FuelPHP
  3. Zend
  4. Yii

Options:

  1. A and B
  2. C and D
  3. A, B, and C
  4. 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?
  1. HTML code
  2. Windows Application code
  3. Java-script code
  4. PHP code

Options:

  1. A and B
  2. A, B, and C
  3. A, C, and D
  4. 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?
  1. Creation of dynamic WebPages.
  2. Add, delete, and modify data in the database.
  3. Encryption and decryption of data.
  4. PHP can send and receive cookies.

Options:

  1. A and B
  2. C and D
  3. A, B, and C
  4. 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?
  1. Yes
  2. No

Correct answer: 1
Yes

Yes, PHP supports AJAX.


10) Which of the following operating systems can run PHP scripts?
  1. MAC OS X
  2. Windows
  3. Linux
  4. Unix

Options:

  1. A and B
  2. C and D
  3. A, B, and C
  4. A, B, C, and D

Correct answer: 4
A, B, C, and D

All given operating systems can run PHP scripts.


11) Which of the following web-server is used for PHP scripts?
  1. Tomcat
  2. IIS
  3. Apache
  4. 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?
  1. LAMP
  2. WAMP
  3. LANP
  4. MAMP

Options:

  1. A and B
  2. C and D
  3. A, B, and D
  4. 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?
  1. Markup
  2. MySQL
  3. Most
  4. 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?
  1. PHP
  2. Python
  3. Perl
  4. 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?
  1. Yes
  2. 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?
  1. print
  2. echo
  3. disp
  4. disptext

Options:

  1. Only A
  2. Only B
  3. A and B
  4. C and D

Correct answer: 3
A and B

The print and echo functions are used to print text on the webpage.


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;
?>
  1. Sum is: 15
  2. Print '15' with a warning
  3. Syntax error
  4. 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;
?>
  1. Sum is: 15
  2. Print '15' with a warning
  3. Syntax error
  4. 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?
  1. Yes
  2. 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>";
?>
  1. Print "<b>Hello World</b>" on the webpage.
  2. Print "Hello World" in bold style on the webpage.
  3. Print "Hello World" without bold style on the webpage.
  4. 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?
  1. # commented line
  2. // commented line
  3. 'commented line
  4. : commented line

Options:

  1. Only A
  2. Only B
  3. A and B
  4. 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;
?>
  1. Sum is: 15
  2. Print "15" with warning
  3. Syntax error
  4. 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;

?>
  1. Sum is: 15
  2. Print "15" with warning
  3. Syntax error
  4. 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;

?>
  1. Sum is: 15
  2. Syntax error
  3. Sum is:
  4. 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";

?>
  1. Sum is: 15
  2. Syntax error
  3. Sum is:
  4. 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?
  1. Yes
  2. No

Correct answer: 1
Yes

Yes, the given statement is true.


Learn PHP programming with our PHP tutorial.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.