<li>Parse Error – Commonly caused due to syntax mistakes in codes e.g. missing semicolon, mismatch brackets.</li>
<li>Fatal Error – These are basically run time errors which are caused when you try to access what can’t be done. E.g. accessing a dead object, or trying to use a function that hasn’t been declared.</li>
<li>Warning Error – These occurs when u try to include a file that is not present, or delete a file that is not on the server. This will not halt the script; it will give the notice and continue with the next line of the script.</li>
<li>Notice Error – These errors occurs when u try to use a variable that hasn’t been declared, this will not halt the script, It will give the notice and continue with the next line of the script.</li>
Q 82 -
What is an associative array?
Associative arrays are arrays that use named keys that you assign to them.
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. It is a data-access abstraction layer, so no matter what database we use the function to issue queries and fetch data will be same. Using PDO drivers we can connect to database like DB2, Oracle, PostgreSQL etc.
Q 84 -
What are the different types of PHP variables?
PHP has a total of eight data types which we use to construct our variables −
<li>Integers − are whole numbers, without a decimal point, like 4195.</li>
<li>Doubles − are floating-point numbers, like 3.14159 or 49.1.</li>
<li>Booleans − have only two possible values either true or false.</li>
<li>NULL − is a special type that only has one value: NULL.</li>
<li>Strings − are sequences of characters, like 'PHP supports string operations.'</li>
<li>Arrays − are named and indexed collections of other values.</li>
<li>Objects − are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.</li>
<li>Resources − are special variables that hold references to resources external to PHP (such as database connections).<br />
Q 85 -
What are the differences between PHP constants and variables?
There is no need to write a dollar sign ($) before a constant, where as in Variable one has to write a dollar sign.
Constants cannot be defined by simple assignment, they may only be defined using the define() function.
Constants may be defined and accessed anywhere without regard to variable scoping rules.
Once the Constants have been set, may not be redefined or undefined.
Q 86 -
Explain the syntax for 'foreach' loop.
The foreach statement is used to loop through arrays. For each pass the value of the current array element is assigned to $value and the array pointer is moved by one and in the next pass next element will be processed.
Example: foreach (array as value)
code to be executed;
Q 87 -
How will you concatenate two strings in PHP?
To concatenate two string variables together, use the dot (.) operator −
echo $string1 . " " . $string2;<br />
This will produce following result −
Hello World 1234<br />
Q 88 -
How will you generate random numbers using PHP?
The PHP rand() function is used to generate a random number. This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated.
Q 89 -
What is the purpse $_REQUEST variable?.
The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE. We will discuss $_COOKIE variable when we will explain about cookies. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.