PHP Set 7 (25 mcqs)

1. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 0;
3.    while ($i = 10)
4.    {
5.print “hi”;
6.    }
7.    print “hello”;
8.    ?>
a) hello
b) infinite loop
c) hihello
d) error

2. What will be the output of the following PHP code ?
1.    <?php
2.    $i = “”;
3.    while ($i = 10)
4.    {
5.print “hi”;
6.    }
7.    print “hello”;
8.    ?>
a) hello
b) infinite loop
c) hihello
d) error

3. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 5;
3.    while (–$i > 0)
4.    {
5.$i++;
6.print $i;
7.print “hello”;
8.    }
9.    ?>
a) 4hello4hello4hello4hello4hello…..infinite
b) 5hello5hello5hello5hello5hello…..infinite
c) no output
d) error

4. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 5;
3.    while (–$i > 0 && ++$i)
4.    {
5.print $i;
6.    }
7.    ?>
a) 5
b) 555555555…infinitely
c) 54321
d) error
.
5. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 5;
3.    while (–$i > 0 || ++$i)
4.    {
5.print $i;
6.    }
7.    ?>
a) 54321111111….infinitely
b) 555555555…infinitely
c) 54321
d) 5

6. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 0;
3.    while(++$i || –$i)
4.    {
5.print $i;
6.    }
7.    ?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) 1
d) 0

7. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 0;
3.    while (++$i && –$i)
4.    {
5.print $i;
6.    }
7.    ?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) no output
d) error
.
8. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 0;
3.    while ((–$i > ++$i) – 1)
4.    {
5.print $i;
6.    }
7.    ?>
a) 00000000000000000000….infinitely
b) -1-1-1-1-1-1-1-1-1-1…infinitely
c) no output
d) error

9. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 2;
3.    while (++$i)
4.    {
5.while ($i –> 0)
6.    print $i;
7.    }
8.    ?>
a) 210
b) 10
c) no output
d) infinite loop

10. What will be the output of the following PHP code ?
1.    <?php
2.    $i = 2;
3.    while (++$i)
4.    {
5.while (–$i > 0)
6.    print $i;
7.    }
8.    ?>
a) 210
b) 10
c) no output
d) infinite loop

11. Which one of the following statements should be used to disable just the fopen(), and file() functions?
a) disable_functions = fopen(),file()
b) disable_functions = fopen,file
c) functions_disable = fopen(),file()
d) functions_disable = fopen,file

12. Which one of the following statements should be used to disable the use of two classes administrator and janitor?
a) disable_classes = “administrator, janitor”
b) disable_classes = class administrator, class janitor
c) disable_classes = class “administrator”, class “janitor”
d) disable_class = class “administrator”, class “janitor”

13. What is the default value of max_execution_time directive? This directive specifies how many seconds a script can execute before being terminated.
a) 10
b) 20
c) 30
d) 40
.
14. The memory_limit is only applicable if ___ is enabled when you configure PHP. Fill in the blank.
a) –enable-limit
b) -enable-memory-limit
c) –enable-memory-limit
d) -memory-limit

15. Suppose all web material is located within the directory /home/www. To prevent users from viewing and manipulating files such as /etc/password, which one of the following statements should you use?
a) open_dir = “/home/www/”
b) open_dir = /home/www/
c) open_basedir = /home/www/
d) open_basedir = “/home/www/”

a) ServerSignature
b) ServerName
c) ServerDetails
d) ServerInfo

17. Which directive determines which degree of server details is provided if the ServerSignature directive is enabled?
a) ServerAddons
b) ServerExtra
c) ServerTokens
d) ServerDetails

18. Which directive should we disable to obscure the fact that PHP is being used on our server?
a) show_php
b) expose_php
c) print_php
d) info_php

19. Say I want to change the extension of a PHP file, which of the following statements should I edit to change from .php to .html in the httpd.conf file?
a) AddType application/x-httpd-php .php
b) AddType application/x-httpd-php .asp
c) AddType application/x-httpd-asp .php
d) AddType application/x-httpd-asp .asp

20. The developers of PHP deprecated the safe mode feature as of which PHP version.
a) PHP 5.1.0
b) PHP 5.2.0
c) PHP 5.3.0
d) PHP 5.3.1

21. What will be the output of the following PHP code?
1.<?php
2.echo (checkdate(4,31,2010) ? ‘Valid’ : ‘Invalid’);
3.?>
a) TRUE
b) FALSE
c) Valid
d) Invalid
.
22. The date() function returns ___ representation of the current date and/or time.
a) Integer
b) String
c) Boolean
d) Float

23. Which one of the following format parameter can be used to identify timezone?
a) T
b) N
c) E
d) I

24. If the format is F then which one of the following will be returned?
a) Complete text representation of month
b) Day of month, with leading zero
c) Daylight saving time
d) Day of month, without zeros

25. What will be the output of the following code? If say date is 22/06/2013.
1.<?php
2.echo “Today is “.date(“F d, Y”)
3.?>
a) Today is 22 June, 2013
b) Today is 22-06-2013
c) Today is 06-22-2013
d) Today is June 22, 2013

Answers

1-b 2-b 3-a 4-b 5-a
6-a 7-c 8-a 9-a 10-d
11-b 12-a 13-c 14-c 15-d
16-a 17-c 18-b 19-a 20-c
21-d 22-b 23-c 24-a 25-d
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *