PHP Interview Questions and Answers

How can we get the IP address of the client/user?

By using $_SERVER["REMOTE_ADDR"]; we can get user/client Ip address. like

What is PHP?

PHP is a web language based on scripts that allows developers to dynamically create generated web pages.

What does the initials of PHP stand for?

PHP means PHP: Hypertext Preprocessor.

How to start session in PHP?

By using function session_start(); function, we can start a session.

then we can assign a value in session like

$_SESSION['userId'] = 1;


What is $_SERVER?

$_SERVER is an array type. Which have information like web server such as paths, headers, and script locations. And also we can get ip address.

What is the difference between include() Function and require() Function?

Both are used to include/loading a file. The difference between them is, if any error while loading the file require() function gives a fatal error and stop the execution. Coming to include(), it will give warning and execute next script.

How can we pass the data to another web pages?

By using sessions, cookies or hidden form fields we can share the data between different pages.

Is it possible to remove the HTML tags from data?

Yes, Using strip_tags() function remove the HTML tags from given htmlstring.

How to declare constant defined in a PHP?

define ("ISPROD", false);
ISPROD is access directly, it will access any where in the application like global variables.

is PHP $ overrides jquery $?

No, both are different PHP is server side and jquery is client side.

List of string functions in PHP

Below are the some of string functions in PHP