PHP Set 2 (30 mcqs)

1. How many error levels are available in PHP?
a) 14
b) 15
c) 16
d) 17

2. What is the description of Error level E_ERROR?
a) Fatal run-time error
b) Near-fatal error
c) Compile-time error
d) Fatal Compile-time error

3. To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed?
a) $date = Date(“22 JUNE 2013″)
b) $date = new Date(“JUNE 22 2013″)
c) $date = DateTime(“22 JUNE 2013″)
d) $date = new DateTime(“22 JUNE 2013″)

4. Which character do the error_reporting directive use to represent the logical operator NOT?
a) /
b) !
c) ~
d) ^

5. Say you want to report error concerned about fatal run-time, fatal compile-time error and core error which statement would you use?
a) error_reporting = E_ALL
b) error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR
c) error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR
d) error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR
.
6. Which version introduced the function error_get_last()?
a) PHP 4
b) PHP 5
c) PHP 5.2
d) PHP 5.3

7. Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?
a) ignore_repeated_errors
b) ignore_repeat_error
c) repeatedly_ignore_error
d) repeated_error_ignore

8. Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog() functions?
a) define_variable()
b) define_log_variable()
c) log_variable()
d) define_syslog_variable()
.
9. Which logging option’s description is, if an error occurs when writing to the syslog, send output to the system console?
a) LOG_CONS
b) LOG_NDELAY
c) LOG_ODELAY
d) LOG_PERROR

10. Which function is responsible for sending a custom message to the system log?
a) systemlog()
b) syslog()
c) log_system()
d) sys_log()

11. Which of the following is/are an external data?
i) Cookies
ii) Input data from a form
iii) Server Variables
iv) Web services data
a) Only ii)
b) ii) and iii)
c) None of the mentioned
d) All of the mentioned

12. How many types of filtering are present in PHP?
a) 3
b) 2
c) 4
d) None

13. Which one of the following filter is used to filter several variables with the same or different filters?
a) filter_var_array()
b) filter_var()
c) filter_input
d) filter_input_array

14. What will be the output of the following PHP code?
1.<?php
2.$num = “123”;
3.if (!filter_var($num, FILTER_VALIDATE_INT))
4.    echo(“Integer is not valid”);
5.else
6.    echo(“Integer is valid”);
7.?>
a) No output is returned
b) Integer is not valid
c) Integer is valid
d) Error

15. Which one of the following does not describe a validating filter?
a) Are used to allow or disallow specified characters in a string
b) Are used to validate user input
c) Strict format rules
d) Returns the expected type on success or FALSE on failure

16. What will be the output of the following PHP code?
1.<?php
2.$var=300;
3.$int_options = array(“options”=>array (“min_range”=>0, “max_range”=>256));
4.if (!filter_var($var, FILTER_VALIDATE_INT, $int_options))
5.    echo(“Integer is not valid”);
6.else
7.    echo(“Integer is valid”);
8.?>
a) No output is returned
b) Integer is not valid
c) Integer is valid
d) Error

17. If the input variable is a string like this “http://www.saåånfoøøundry.com/”, the $url variable after the sanitizing will look like
a) http://www.saåånfoøøundry.com/
b) http://www.saaanfoooundry.com/
c) http://www.saånfoøundry.com/
d) http://www.sanfoundry.com/

18. Which one of the following filter checks if variable of specified type exists?
a) filter_has_var
b) filter_var
c) filter_id
d) filter_var_array

19. What will be the output of the following PHP code?
1.<?php
2.$value = ‘car’;
3.$result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
4.?>
a) FALSE
b) TRUE
c) NULL
d) ERROR

20. What will be the output of the following PHP code?
1.<?php
2.function convertSpace($string)
3.{
4.    return str_replace(“_”, ” “, $string);
5.}
6.$string = “Peter_is_a_great_guy!”;
7.echo filter_var($string, FILTER_CALLBACK, array(“options”=>”convertSpace”));
8.?>
a) Peter_is_a_great_guy!
b) Peterisagreatguy!
c) Peter is a great guy!
d) Error

21. Before you can start processing images with PHP, you must first add the ability to upload images to your administrative form on ___.
a) .htaccess
b) function.inc.php
c) index.php
d) admin.php

22. When you’re uploading files you need to set the enctype of the form to ___.
a) text
b) text/file
c) multipart/form-data
d) multimedia/form-data

23. To check whether a file was uploaded, you look in the ___ superglobal array.
a) $_FILES
b) $_DOCS
c) $_DOCUMENTS
d) $_FOLDERS

24. To make the ImageHandler class portable you should create a separate file for it called ___.
a) imagehandler.inc.php
b) images.inc.php
c) handler.inc.php
d) imghandler.inc.php

25. DocBlocks are indicated by opening a comment using ___.
a) /*
b) //*
c) /**
d) /*/

26. To process the file, you need to break the array from $_FILES into individual values. You can do this using the ___ function.
a) divide()
b) list()
c) break()
d) indi()
.
27. Before you try to process the file, you need to make sure that your $err value is equivalent to ___.
a) UPLOAD_ERR_OK
b) UPLOAD_NO_ERR
c) UPLOAD_ERR_NO_OK
d) UPLOAD_ERR
.
28. You use the $_SERVER superglobal and your ___ property to create your path to check.
a) $load_dir
b) $load
c) $save
d) $save_dir

29. Which function do you have to use to check whether the $path you’ve stored exists?
a) path_dir()
b) path()
c) is_dir()
d) path_dir()

30. Which one of the following is true about the following line – $obj = new ImageHandler(‘/images/’, array(400, 300));
a) This snippet sets the maximum dimensions allowed to 400 pixels wide by 300 pixels high.
b) This snippet sets the minimum dimensions allowed to 300 pixels wide by 400 pixels high.
c) This snippet sets the minimum dimensions allowed to 400 pixels wide by 300 pixels high.
d) This snippet sets the maximum dimensions allowed to 300 pixels wide by 400 pixels high.

 

Answers

1-c 2-a 3-d 4-c 5-d
6-c 7-a 8-d 9-a 10-b
11-d 12-b 13-a 14-c 15-a
16-b 17-d 18-a 19-c 20-c
21-d 22-c 23-a 24-b 25-c
26-b 27-a 28-d 29- c 30- a

Sharing is caring!

Leave a Comment

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

shares