Correct Answer: mysql_fetch_array: Fetch a result row as an associative array and a numeric array mysql_fetch_object: Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows mysql_fetch_row(): Fetches one row of data from the result associated with the specified result identifier The row is returned as an array Each result column is stored in an array offset, starting at offset 0
2. What is the functionality of the function strstr and stristr?
Correct Answer: strstr() returns part of a given string from the first occurrence of a given substring to the end of the string For example: strstr("user@examplecom","@") will return "@examplecom" stristr() is idential to strstr() except that it is case insensitive
Correct Answer: Notices: These are trivial, non-critical errors that PHP encounters while executing a script - for example, accessing a variable that has not yet been defined By default, such errors are not displayed to the user at all - although, as you will see, you can change this default behaviour Warnings: These are more serious errors - for example, attempting to include() a file which does not exist By default, these errors are displayed to the user, but they do not result in script termination Fatal errors: These are critical errors - for example, instantiating an object of a non-existent class, or calling a non-existent function These errors cause the immediate termination of the script, and PHP?s default behaviour is to display them to the user when they take place
4. How can we extract string "abc.com" from a string "https://info@abc.com" using regular _expression of php?
Correct Answer: We can use the preg_match() function with ?/*@(*)$/? as the regular expression pattern For example: preg_match("/*@(*)$/","https://info@abccom",$data); echo $data[1]; ?>
5. Explain include(), include_once, require() and require_once.
Correct Answer: include() The include() function takes all the content in a specified file and includes it in the current file If an error occurs, the include() function generates a warning, but the script will continue execution include_once() File will not be included more than once If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once() require() The require() function is identical to include(), except that it handles errors differently The require() generates a fatal error, and the script will stop require_once() The required file is called only once when a page is open and further calling of the file will be ignored
Correct Answer: setcookie('variable','value','time'); variable - name of the cookie variable value - value of the cookie variable time - expiry time Example: Test - cookie variable name $i - value of the variable 'Test' time()+3600 - denotes that the cookie will expire after an one hour
7. How can we know the number of days between two given dates using php?
Correct Answer: Array Descriptions -------------------------------- ----------------------------------- $_FILES['userfile']['name'] The original name of the file on the client machine $_FILES['userfile']['type'] The MIME type of the file if the browser provided this information An example would be "image/gif" $_FILES['userfile']['size'] The size, in bytes, of the uploaded file $_FILES['userfile']['tmp_name'] The temporary filename of the file in which the uploaded file was stored on the server $_FILES['userfile']['error'] The error code associated with this file upload
Correct Answer: CONSTRUCTOR : PHP allows developers to declare constructor methods for classes Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++ The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence