PHP is a server side language. PHP is an important part of web application. It is rich and secure web languate to build web application. Every web applicaton developer should have the base knowledge in PHP.
Here we come to assist you most common interview question for job preparation.
1. First Question and most common question is : What is PHP?
PHP is server side scripting language. PHP is an object oriented programming language as like C-sharp , jave. PHP is a powerful language to build in a dynamic and secure Web pages. PHP is free, widely used Programming language and good alternative of Microsoft's ASP. PHP has vast source such as PHP has many Frameworks and CMS. For example Wordpress, Oscommerce are the most popular CSM of PHP. Even a non programmer can easily create sites using those CMS.
2. What’s the difference between the include() and require() functions?
Those two functions perform similar work. Both function is used to connect any specific file. But main difference between those two functions that require() function display a fatal error while require() function doesn't find that specific file.
<?php
require('specific file path here');
?>
on the other hand include() function doesn't show any fatal error if include() function doesn't find that specific file.
<?php
include('specific file path here');
?>
If any file is essential for your project or without that file your project doesn't run well. In that case we recommend you to use require() function else we recmmend you to use include() function.
3. How can we get the IP address of the client?
This question mainly asked to know how creative the candidate is because there are many option to get the IP address of the client. Easiest solution is $_SERVER["REMOTE_ADDR"]; But sometime $_SERVER["REMOTE_ADDR"] doesn't show real IP. It show client proxy IP. $_SERVER["REMOTE_ADDR"] is used to get real IP.
4. What’s the difference between unset() and unlink() ?
In PHP unlink() functions are used to delete a file permanantly from the project. On the other hand unset() functions are used to remove contents or make it undefine instead of deleting a file permanently for the directory.
5. What are the main error types in PHP and how do they differ?
In PHP you can get three type of errors:
Notices – Non-critical errors that are occurred during the script execution. For an example of this Notice can be shown for accessing an undefined variable.
Warnings – More important errors than Notices. In that situation the scripts continue the execution. For example include() a file that does not exist.
Fatal – This type of error doesn't ignore and it stop the script execution.
6. What is the difference between GET and POST?
GET submition data pass through the URL and POST encoded data in the request.
GET can handle a maximum of 2048 characters through the URL on the other hand POST has no such limitation.
GET allows only ASCII data. In that case POST has no restrictions.
GET is used to get data while POST to insert and update.
7. How can you enable error reporting in PHP?
It can enable in php.ini file by check on display_errors. It also can enable by ini_set('display_errors', 1) in the php script. error_reporting(E_ALL) Enabling error messages is very important while developing project.
8. What are Traits?
Trait is one of powerful features of PHP. Traits allow to create reusable code in PHP.
9. Can you extend a Final defined class?
Not at all, It is not possible to extend a Final defined class. It is decalare to prevents child class access.
10. What are the __construct() and __destruct() methods in a PHP class?
The __constructor() method is called immediately after a new instance of the class is being createdThe Destructor method use to destroy a variable or session.
Comments: 1
by business tips
by Calixto