PHP(Hypertext Preprocessor) most commonly asked Interview questions and answers are explain in simple language. PHP interview questions and answers are useful for both fresher’s and experience.
1. What is PHP?
PHP is acronym for Hypertext Preprocessor. It is open source web development scripting language. Servers are required for executing PHP scripts.
2. PHP Object Oriented or Procedure Oriented?
In PHP 5, many OOPS concepts were supported by PHP5, thus it is Object Oriented Language as well as Procedure Oriented Language. OOPS concepts are used along with procedure oriented features.
3. Write Hello World program using PHP?
Hello World program is used to print simple text, “Hello World”
echo “Hello World”;
4. Why PHP is called as Loosely Type Language?
PHP is called has Loosely Typed Language because, in PHP we not declare variable data type (like integer, short, string etc.). PHP will automatically give best suited variable data type.
5. Does PHP syntax are similar with any programming language?
Yes, PHP Scripting language has similar syntax as of Java and Perl programming language.
6. Difference between GET and POST Method?
- GET and POST both are used for sending information to server. Though there are many difference between GET and POST:
- GET appends the value in the URL whereas POST does not append values in the URL
- GET values are publicly available(because it values are appended in the URL) and POST is secure.
- GET can send limited amount of data( because URL only supports 1024 characters) and POST can send any amount of information.
7. What are the types of errors in PHP?
The different types of PHP errors are: E_ERROR, E_WARNING, E_PARSE, E_NOTICE, E_USER_ERROR, E_USER_NOTICE, E_CORE_WARNING etc.
8. What are the different types of runtime errors in PHP?
There are mainly three types of runtime errors in PHP. They are Notices, Warnings and Fatal Errors. Notices are small errors which are not visible to users whereas warning are severe errors and it those errors are visible to users. Fatal errors are extremely severe errors which will stop PHP script execution.
9. Difference between Require and Include?
Require and Include statements are similar except during failure or errors. Require statement produces or results fatal error and it stops executing the script during failure whereas include statement does not stops scripts, just it shows warning.
10. What are the types of PHP Variables Scope?
PHP has three variable scope. They are: local, global and static. A local variable is declared inside the function whereas global variable is declared outside the functions. Local variable have access within the function only and global variable can be access from any function.