Php Interview Question and Answer
Php Interview Question and Answer
most commonly asked interview Question. We generally aware about the term asked in interview but we can’t reply correctly in interview.
The following interview Question will help.
1) What is PHP ?
PHP(recursive acronym for PHP: Hypertext Preprocessor) is a server side scripting language .it is widely used for open source scripting language, commonly used for web applications and can be embedded into HTML. PHP has many frameworks. Lots of CMS developed using PHP.
2) What is the difference between echo and print?
Echo and print statements are both used to output data and near about similar in action. The differences between echo and print statement are Echo has no return value while print has a return value of 1. Echo can take multiple arguments while print can take one argument. Echo is slightly faster than print .
3) How to include a file in php ?
To insert the content of one php file to another we can use “include() ” or “require()” function with file path as its parameter.
4) What’s the difference between include and require statements?
To insert the content of one PHP file into another PHP file we use the include or require statement.
The include and require statements are same and identical, but difference in the following points :
- If file not found require will produce a fatal error and stop the execution of the script
- If file not found include will only produce a warning and the script will continue execution.
5) What is difference between require_once(), require(), include() ?
require_once() includes only one time on the same page.
require() includes and evaluates a specific file many time in the same page
If file not found include will only produce a warning and the script will continue execution while require will show fatal error.
6) Differences between GET and POST methods ?
GET and POST methods are used to request and response between a client and server
- GET – Requests data from a specified resource and can transfer 1024 bytes data
- GET – requests can be cached
- GET – requests remain in the browser history
- GET – requests can be bookmarked
- POST – Submits data to be processed to a specified resource and can transfer large amount of data
- POST – requests are never cached
- POST – requests do not remain in the browser history
- POST – requests cannot be bookmarked
7) What is HTTP ?
The HTTP ( Hypertext Transfer Protocol) is used communicate between clients and servers.
HTTP works as a request-response protocol between a client and server.
A web browser may be the client, and an application on a computer that hosts a web site may be the server.
8) What are the different types of errors in PHP ?
Different types of error in php
– E_ERROR: A fatal error that causes script termination
– E_WARNING: Run-time warning that does not cause script termination
– E_PARSE: Compile time parse error.
– E_NOTICE: Run time notice caused due to error in code
– E_CORE_ERROR: Fatal errors that occur during PHP’s initial startup (installation)
– E_CORE_WARNING: Warnings that occur during PHP’s initial startup
– E_COMPILE_ERROR: Fatal compile-time errors indication problem with script.
– E_USER_ERROR: User-generated error message.
– E_USER_WARNING: User-generated warning message.
– E_USER_NOTICE: User-generated notice message.
– E_STRICT: Run-time notices.
– E_RECOVERABLE_ERROR: Catchable fatal error indicating a dangerous error
– E_ALL: Catches all errors and warnings
Basic types of runtime errors :
1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script By default, such errors are not displayed to the user at all – although you can change this default behavior.
2. Warnings: These are more serious errors. By default, these errors are displayed to the user, but they do not result in script termination.
8) Waht is MIME ?
MIME – Multi-purpose Internet Mail Extensions.
MIME types represents a standard way of classifying file types over Internet.
Web servers and browsers have a list of MIME types, which facilitates files transfer of the same type in the same way, irrespective of operating system they are working in.
9) What is session in php ?
A session is the process to store information in variables to be used across multiple pages.
Session variables stores information about one single user, and are available to all pages in one application.
before storing session we have to start session by using session_start() function.
10) What is cookie ?
A cookie is a small piece of information.A cookie is a small file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too. We can store and retrieve cookie value.
store information into cookie
setcookie(name, value, expire, path, domain, secure, httponly);
for more information pleases visit Manual