PS Exam

  • Full Screen
  • Wide Screen
  • Narrow Screen
  • Increase font size
  • Default font size
  • Decrease font size

PHP - Multiple Choice Questions (MCQs) - Objective Questions Set 1

E-mail Print PDF

Following are the Multiple Choice Questions (MCQs) or Objective Questions from PHP (PHP: Hypertext Preprocessor)

Set - 1

 This set contains 20 objective questions with 4 options each. The correct answer is provided at the end of the page.

1.      A script is a
a.       Program or sequence of instructions that is interpreted or carried out by processor directly
b.      Program or sequence of instruction that is interpreted or carried out by another program
c.       Program or sequence of instruction that is interpreted or carried out by web server only
d.      None of above
 

3.      When compared to the compiled program, scripts run
a.       Faster
b.      Slower
c.       The execution speed is similar
d.      All of above
 

4.      PHP is a widely used ……………. scripting language that is especially suited for web development and can be embedded into html
a.       Open source general purpose
b.      Proprietary general purpose
c.       Open source special purpose
d.      Proprietary special purpose
 

5.      Which of the following is not true?
a.       PHP can be used to develop web applications.
b.      PHP makes a website dynamic.
c.       PHP applications can not be compiled.
d.      PHP can not be embedded into html.
 

6.      The most portable version of PHP tag that is compatible to embed in XML or XHTML too is:
a.       <? ?>
b.      <script language=”php”> </script>
c.       <% %>
d.     
 

7.      Which of the following variables is not a predefined variable?
a.       $get
b.      $ask
c.       $request
d.      $post
 

8.      You can define a constant by using the define() function. Once a constant is defined
a.       It can never be changed or undefined
b.      It can never be changed but can be undefined
c.       It can be changed but can not be undefined
d.      It can be changed and can be undefined
 

9.      The following piece of script will output:
<?
$email=’admin@psexam.com’;
$new=strstr($email, ‘@&rsquoWink;
print $new;
?>
a.       admin
b.      admin@psexam
c.       @psexam.com
d.      psexam.com
 

10. Which of the following function returns the number of characters in a string variable?
a.       count($variable)
b.      len($variable)
c.       strcount($variable)
d.      strlen($variable)
 

11. When you need to obtain the ASCII value of a character which of the following function you apply in PHP?
a.       chr( );
b.      asc( );
c.       ord( );
d.      val( );
 

12. A variable $word is set to “HELLO WORLD”, which of the following script returns in title case?
a.       echo ucwords($word)
b.      echo ucwords(strtolower($word)
c.       echo ucfirst($word)
d.      echo ucfirst(strtolower($word)
 

13. The difference between include() and require()
a.       are different how they handle failure
b.      both are same in every aspects
c.       is include() produced a Fatal Error while require results in a Warning
d.      none of above
 

14. When a file is included the code it contains, behave for variable scope of the line on which the include occurs
a.       Any variable available at that line in the calling file will be available within the called file from that point
b.      Any variable available at that line in the calling file will not be available within the called file
c.       Variables are local in both called and calling files
d.      None of above
 

15. Which of the following method sends input to a script via a URL?
a.       Get
b.      Post
c.       Both
d.      None
 

16. Which of the following method is suitable when you need to send larger form submissions?
a.       Get
b.      Post
c.       Both Get and Post
d.      There is no direct way for larger form. You need to store them in a file and retrieve
 

17. Which of the following mode of fopen() function opens a file only for writing. If a file with that name does not exist, attempts to create anew file. If the file exist, place the file pointer at the end of the file after all other data.
a.       W
b.      W+
c.       A
d.      A+
 

18. The function setcookie( ) is used to
a.       Enable or disable cookie support
b.      Declare cookie variables
c.       Store data in cookie variable
d.      All of above
 

19. To work with remote files in PHP you need to enable
a.       allow_url_fopen
b.      allow_remote_files
c.       both of above
d.      none of above
 

20. fopen($file_doc,”r+&rdquoWink opens a file for
a.       reading
b.      writing
c.       none of above
d.      both of above
 
 


 

 

 

Answers:



1.      A script is a
b.      Program or sequence of instruction that is interpreted or carried out by another program

3.      When compared to the compiled program, scripts run
b.      Slower 

4.      PHP is a widely used ……………. scripting language that is especially suited for web development and can be embedded into html
a.       Open source general purpose 

5.      Which of the following is not true?
d.      PHP can not be embedded into html. 

6.      The most portable version of PHP tag that is compatible to embed in XML or XHTML too is:
d.       

7.      Which of the following variables is not a predefined variable?
b.      $ask 

8.      You can define a constant by using the define() function. Once a constant is defined
a.       It can never be changed or undefined

9.      The following piece of script will output:
<?
$email=’admin@psexam.com’;
$new=strstr($email, ‘@&rsquoWink;
print $new;
?>
c.       @psexam.com

10. Which of the following function returns the number of characters in a string variable?
d.      strlen($variable) 

11. When you need to obtain the ASCII value of a character which of the following function you apply in PHP?
c.       ord( );

12. A variable $word is set to “HELLO WORLD”, which of the following script returns in title case?
b.      echo ucwords(strtolower($word)

13. The difference between include() and require()
a.       are different how they handle failure 

14. When a file is included the code it contains, behave for variable scope of the line on which the include occurs
a.       Any variable available at that line in the calling file will be available within the called file from that point 

15. Which of the following method sends input to a script via a URL?
a.       Get 

16. Which of the following method is suitable when you need to send larger form submissions?
b.      Post 

17. Which of the following mode of fopen() function opens a file only for writing. If a file with that name does not exist, attempts to create anew file. If the file exist, place the file pointer at the end of the file after all other data.
c.      

18. The function setcookie( ) is used to
c.       Store data in cookie variable

19. To work with remote files in PHP you need to enable
a.       allow_url_fopen

20. fopen($file_doc,”r+&rdquoWink opens a file for
d.      both of above 

 

Subscribe

Wish to get contents in your Email?

Enter your email address:

Who's Online

We have 74 guests online

Sharing Enriches!

You are here: MCQ Bank php PHP - Multiple Choice Questions (MCQs) - Objective Questions Set 1