Friday, 27 April 2012

PHP Interview question 9


26) What are the different types of errors in PHP?
Ans :      Three are three types of errors:
1. 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 behavior.
2. 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.3.
3.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 behavior is to display them to the user when they take place.

27) What is the functionality of the function strstr and stristr?
Ans :      strstr Returns part of string from the first occurrence of needle(sub string that we finding out ) to the end of string.
$email= 'sonialouder@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
here @ is the needle
stristr is case-insensitive means able not able to diffrenciate between a and A

28) What are the differences between PHP 3 and PHP 4 and PHP 5?
Ans : There are lot of difference among these three version of php
1>Php3 is oldest version after that php4 came and current version is php5 (php5.3) where php6 have to come
2>Difference mean oldest version have less functionality as compare to new one like php5 have all OOPs concept now where as php3 was pure procedural language constructive like C
In PHP5 1. Implementation of exceptions and exception handling
2. Type hinting which allows you to force the type of a specific argument
3. Overloading of methods through the __call function
4. Full constructors and destructors etc through a __constuctor and __destructor function
5. __autoload function for dynamically including certain include files depending on the class you are trying to create.
6 Finality : can now use the final keyword to indicate that a method cannot be overridden by a child. You can also declare an entire class as final which prevents it from having any children at all.
7 Interfaces & Abstract Classes
8 Passed by Reference :
9 An __clone method if you really want to duplicate an object
10 Numbers of Functions Deprecated in php 5.x like ereg,ereg_replace,magic_quotes_runtime, session_register,register_globals, split(), call_user_method() etc
                 
29) How can we convert asp pages to PHP pages?
Ans :      there are lots of tools available for asp to PHP conversion. you can search Google for that. the best one is available at http://asp2php.naken.cc./

30) What is the functionality of the function htmlentities?
Ans :      Convert all applicable characters to HTML entities
This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

No comments:

Post a Comment