PHP Reviewer Flashcards
Q 1 - Which of the following is correct about PHP?
A - PHP can access cookies variables and set cookies.
B - Using PHP, you can restrict users to access some pages of your website.
C - It can encrypt data.
D - All of the above.
D - All of the above.
Q 2 - Which of the following type of variables have only two possible values either true or false?
A - Integers
B - Doubles
C - Booleans
D - Strings
C - Booleans
Q 3 - Which of the following magic constant of PHP returns function name?
A - LINE
B - FILE
C - __FUNCTION__
D - CLASS
C - FUNCTION
Q 4 - Which of the following function is used to locate a string within a string?
A - search()
B - locate()
C - strpos()
D - None of the above.
C - strpos()
Q 5 - Which of the following variable is used for the PHP script name?
A - $_PHP_SELF
B - $SELF
C - $PHP
D - None of the above.
A - $_PHP_SELF
Q 6 - If there is any problem in loading a file then the require() function generates a warning but the script will continue execution.
A - true
B - false
B - false
Q 7 - Which of the following is used to create a session?
A - session_start() function
B - $_SESSION[]
C - isset() function
D - session_destroy() function
A - session_start() function
Q 8 - Which of the following is used to destroy the session?
A - session_start() function
B - $_SESSION[]
C - isset() function
D - session_destroy() function
D - session_destroy() function
Q 9 - Which of the following method of Exception class returns the code of exception when error occured?
A - getMessage()
B - getCode()
C - getFile()
D - getLine()
B - getCode()
Q 10 - Which of the following method acts as a destructor function in a PHP class?
A - class_name()
B - __destruct
C - destructor
D - None of the above.
B - __destruct
a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
PHP
What does PHP stand for
PHP: Hypertext Preprocessor
What are the common usage of PHP?
- PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
- PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.
- You add, delete, modify elements within your database thru PHP.
- Access cookies variables and set cookies.
- Using PHP, you can restrict users to access some pages of your website.
- It can encrypt data.
In how many ways you can embed PHP code in an HTML page?
All PHP code must be included inside one of the three special markup tags ate are recognised by the PHP Parser.
<?php PHP code goes here ?>
<? PHP code goes here ?>
PHP code goes here
Most common tag is the <?php…?>
- final and most immediate way to affect PHP’s functionality
- read each time PHP is initialized
php.ini
The PHP parsing engine needs a way to differentiate PHP code from other elements in the page. The mechanism for doing so is known as?
‘escaping to PHP.’
means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.
PHP is whitespace insensitive
Characteristics of PHP variables
All variables in PHP are denoted with a leading dollar sign ($).
The value of a variable is the value of its most recent assignment.
Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
Variables can, but do not need, to be declared before assignment.
Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters.
Variables used before they are assigned have default values.
PHP does a good job of automatically converting types from one to another when necessary.
PHP variables are Perl-like.
What are rules for naming a PHP variable?
- Rules for naming a variable are following
- Variable names must begin with a letter or underscore character.
- A variable name can consist of numbers, letters, underscores but you cannot use characters like + , - , % , ( , ) . & , etc
Q - Which of the following is used to get information sent via get method in PHP?
A - $_GET
B - $GET
C - $GETREQUEST
D - None of the above.
A - $_GET
Q - Which of the following method acts as a constructor function in a PHP class?
A - class_name()
B - __construct
C - constructor
D - None of the above.
B - __construct
Q - Which of the following function sorts an array in reverse order?
A - rsort()
B - sort()
C - shuffle()
D - reset()
A - rsort()
Q - Which of the following magic constant of PHP returns class name?
A - LINE
B - FILE
C - FUNCTION
D - CLASS
D - CLASS
Q - Which of the following method of Exception class returns formated string of trace?
A - getMessage()
B - getCode()
C - getTrace()
D - getTraceAsString()
D - getTraceAsString()
Q - Which of the following is used to check that a cookie is set or not?
A - getcookie() function
B - $_COOKIE variable
C - isset() function
D - None of the above.
C - isset() function
Q - Which of the following array represents an array with a numeric index?
A - Numeric Array
B - Associative Array
C - Multidimentional Array
D - None of the above.
A - Numeric Array
Q - Which of the following is true about php variables?
A - All variables in PHP are denoted with a leading dollar sign ($).
B - The value of a variable is the value of its most recent assignment.
C - Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
D - All of the above.
D - All of the above.
Q - Which of the following type of variables are special type that only has one value: NULL?
A - Strings
B - Doubles
C - Booleans
D - NULL
D - NULL
Q - Which of the following is correct about PHP?
A - PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
B - PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data, return data to the user.
C - You add, delete, modify elements within your database thru PHP.
D - All of the above.
D - All of the above.
Q - Which of the following can be used to get information sent via get/post method in PHP?
A - $_REQUEST
B - $REQUEST
C - $REQUEST_PAGE
D - None of the above.
A - $_REQUEST
Q - Which of the following function is used to get environment variables in PHP?
A - search()
B - environment()
C - env()
D - getenv()
D - getenv()
Q - Which of the following method connect a MySql database using PHP?
A - mysql_connect()
B - mysql_query()
C - mysql_close()
D - None of the above
A - mysql_connect()
Q - Which of the following magic constant of PHP returns current line number of the file?
A - LINE
B - FILE
C - FUNCTION
D - CLASS
A - LINE
Q - Can you assign the default values to a function parameters?
A - true
B - false
A - true
Q - Which of the following is an associative array of variables passed to the current script via HTTP cookies?
A - $GLOBALS
B - $_SERVER
C - $_COOKIE
D - $_SESSION
C - $_COOKIE
Q - Which of the following type of variables are whole numbers, without a decimal point, like 4195?
A - Integers
B - Doubles
C - Booleans
D - Strings
A - Integers
Q - Which of the following provides the actual name of the uploaded file?
A - $_FILES[‘file’][‘tmp_name’]
B - $_FILES[‘file’][‘name’]
C - $_FILES[‘file’][‘size’]
D - $_FILES[‘file’][‘type’]
B - $_FILES[‘file’][‘name’]
Q - Which of the following is used to set cookies?
A - setcookie() function
B - $_COOKIE variable
C - $HTTP_COOKIE_VARS variable
D - isset() function
A - setcookie() function
Q - Which of the following magic constant of PHP returns function name?
A - LINE
B - FILE
C - FUNCTION
D - CLASS
C - FUNCTION
Q 1 - Which of the following is correct about PHP?
A - PHP is a recursive acronym for “PHP: Hypertext Preprocessor”.
B - PHP is a server side scripting language that is embedded in HTML.
C - It is used to manage dynamic content, databases, session tracking, even build entire e-commerce
sites.
D - All of the above.
D
Q 2 - Which of the following is correct about PHP?
A - PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close
them.
B - PHP can handle forms, i.e. gather data from files, save data to a file, thru email you can send data,
return data to the user.
C - You add, delete, modify elements within your database thru PHP.
D - All of the above.
D