Test Series - php

Test Number 1/39

Q: What does PHP stand for?

   i) Personal Home Page
   ii) Hypertext Preprocessor
   iii) Pretext Hypertext Processor
   iv) Preprocessor Home Page
A. Both i) and iii)
B. Both ii) and iv)
C. Only ii)
D. Both i) and ii)
Solution: PHP previously stood for Personal Home Page now stands for Hypertext Preprocessor.
Q: PHP files have a default file extension of_______
A. .html
B. .xml
C. .php
D. .ph
Solution: To run a php file on the server, it should be saved as AnyName.php
Q: What should be the correct syntax to write a PHP code?
A. < php >
B. < ? php ?>
C. 
D. 
Solution: Every section of PHP code starts and ends by turning on and off PHP tags to let the server know that it needs to execute the PHP in between them.
Q: Which of the following is/are a PHP code editor?

    i) Notepad
    ii) Notepad++
    iii) Adobe Dreamweaver
    iv) PDT
A. Only iv)
B. i), ii), iii) and iv)
C. i), ii) and iii)
D. Only iii)
Solution: Any of the above editors can be used to type php code and run it.
Q: Which of the following must be installed on your computer so as to run PHP script?

i) Adobe Dreamweaver 
ii) XAMPP
iii) Apache and PHP
iv) IIS
A. i), ii), iii) and iv)
B. Only ii)
C. ii) and iii)
D. ii), iii) and iv)
Solution: To run PHP code you need to have PHP and a web server, both IIS and Apache are web servers. You can choose either one according to your platform.
Q: Which version of PHP introduced Try/catch Exception?
A. PHP 4
B. PHP 5
C. PHP 6
D. PHP 5 and later
Solution: PHP 5 version and later versions added support for Exception Handling.
Q: How should we add a single line comment in our PHP code?

    i) /?
    ii) //
    iii) #
    iv) /* */
A. Only ii)
B. i), iii) and iv)
C. ii), iii) and iv)
D. Both ii) and iv)
Solution: /* */ can also be use to comment just a single line although it is used for paragraphs. // and # are used only for single line comment.
Q: Which of the following PHP statement/statements will store 111 in variable num?

    i) int $num = 111;
    ii) int mum = 111;
    iii) $num = 111;
    iv) 111 = $num;
A. Both i) and ii)
B. i), ii), iii) and iv)
C. Only iii)
D. Only i)
Solution: You need not specify the datatype in php.
Q: What will be the output of the following PHP code?

    
A. 3
B. 1+2
C. 1.+.2
D. Error
Solution: .(dot) is used to combine two parts of the statement. Example ($num . “Hello World”) will output 1Hello World.
Q: What will be the output of the following PHP code?

    
A. 3
B. 1+2
C. Error
D. 12
Solution: The numbers inside the double quotes are considered as integers and not string, therefore the value 3 is printed and not 1+2.

You Have Score    /10