PHP Interview Questions are asked by IT company for php developer job as below. We should prepare below questions before attending interview for web developer job.
1.What is PHP?
PHP is a Hypertext Preprocessor web based scripting language that allow developers to create web pages dynamically.
2. What is the purpose of php.ini file?
php.ini is PHP configuration file. The php.ini file is the final and most immediate way to affect PHP's functionality. The php.ini file is used to set memory_limit, enable_safe_mode, register_globals, upload_max_filesize, upload_tmp_dir, post_max_size, display_errors, error_reporting, max_execution_time, short_open_tags, session.save-handler, include_path , doc_root, mysql variable, cookies variable etc.
3. What is the difference between 'echo' and 'print' in PHP?
Echo is statement and print is function.
Echo can output one or more string but print can only output one string and always returns 1.
Echo is faster than print because it does not return any value.
4. What does PEAR stand for?
PEAR means "PHP Extension and Application Repository". It extends PHP and provides a higher level of programming for web developers.
5. How will you define a constant in PHP?
The define() function and const() function are used to define a constant in PHP.
6. How a variable is declared in PHP?
A variable can be declared in PHP using dollar ($) sign in front of variable name.
i.e $varname="PHP Variable";
7. What are PHP magic constants?
Magic constants are the predefined constants in PHP. PHP magic constants are given as below.
__LINE__
__FILE__
__DIR__
__FUNCTION__
__CLASS__
__TRAIT__
__METHOD__
__NAMESPACE__
ClassName::class
8. What is the difference between include() Function and require() Function?
The require() function generates a fatal error if file is not found and halt the execution of the script whereas include() function generates a warning if file is not found but the script will continue execution.
9.What is the use of final keyword?
The final keyword can be used to prevent class inheritance. Final class can not be inherited by another class. final class cannot be extended.
The final keyword can be used to prevent method overriding. Final Method of parent class can not be overriden by method of child class.
10. What is interfaces in PHP?
Interfaces is referred to as polymorphism. All methods of Interfaces should be implemented in class. Interfaces are declared with the interface keyword.Interfaces cannot have properties. All interface methods must be public.
11. How will you send an email using PHP?
The mail() function is used to send an email. The mail() function has below arguments.
mail($to,$subject,$message,$headers,$parameters);
12. How will you start a session in PHP?
The session_start() function is used to start a session in PHP.
It is recommended to put session_start() function at the beginning of the page.
13.What is the difference between $ and $$?
$ sign is used to store variable value. $$ sign is used to store variable of variables.
Comments