100 PHP’s possible interview questions and answers for fresher- Part 1

  • Home -
  • 100 PHP’s possible interview questions and answers for fresher- Part 1

1) What is PHP?

PHP is a server side web programing language which is used to develop data driven dynamic websites.

 

2) What does PHP stand for?

PHP stands for Hypertext Preprocessor

 

3) Which programing languages PHP resembles to?

PHP syntax is very similar to ‘C ‘ language.

 

4) Mention two other popular server side popular web programing languages which are parallel to PHP.

ASP.NET and JSP are two other server side programing language/technologies which are also popular.

 

5) Which is the latest version of PHP?

PHP 7.x is the latest and recommended version for PHP developers.

 

6) Is it possible to run PHP code from command line?

Yes, using PHP CLI or command line interface it’s possible to execute the PHP program. Like this : php script.php

 

7) What are XAMPP and WAMPP?

XAMPP and WAMPP are software packages which if installed , it installs all necessary software in local host to run PHP such as it installs PHP, MySql,PHPMyAdmin and filezilla also.

 

8. What is difference between variable and constants?

Variables are characters which are used to hold the data in temporary memory.
The value of variable changes during program execution.
Constant is also like variable but the difference is that once its value is defined, its does not change during program execution.
To declare variable we use $ sign while to declare constant we use define () pre-defined function.
$x=10 variable
define(‘site’,’http://www.acesoftech.com’)is constant example.

 

9. What is main difference between JAVA and PHP?

JAVA is multi-purpose software through which one can develop desktop, mobile as well as web applications.
PHP is a server side web programing language which is used to develop web applications.
Java is a compiled language while PHP is an interpreted language.
Java is a strongly typed language while PHP is a loosely typed language.

 

10) What is modulo operator and where it is used?

% is called module operator. It’s used to find whether the given number is odd or even. It is used to find remainder of the number. Example: 20%2 the remainder will be 0.

 

11. What is difference between echo and print?

echo can display multiple parameter in single statement.
echo “Hello”,”World”; is fine
Print does not show multiple parameters in single statement
echo “Hello”,”World”; error
print behaves like a function and returns 0 , that’s why its slower
echo does not return any value and its faster than print.

 

12) What is the main difference between PHP 4 and PHP 5?

PHP 4 was a procedural programing language while PHP is an object-oriented language.

 

13) Is multiple inheritances supported in PHP?

No, multiple inheritance is not supported in PHP because of ambiguity problem. Yes, multi-level inheritance is supported in PHP.

 

14) What is difference between final and finally?

When a class is defined as ‘final ‘, that means it cannot be inherited by its child classes. ‘Finally’ is used to put important code which will run in any case whether error is caught or not.

 

15) What is a final method?

When we put final keyword before any method, then that method cannot be over-ridden.

 

16) What is difference between method overriding and method over-loading?

When same method exists in base class as well as child class, and object of child class invokes the method then the base class method is overridden and the value of child class method is displayed, and this is called method overriding.
When method name is same but it performs different task based on parameters, is called method overloading.

 

17) How two objects are compared in PHP?

‘==’ operator is used to compare two objects to see if two objects are instanced from the same class and have same attributes and equal values. Also we can check if two objects are referring to the same instance of the same class by the use of the identity operator ‘===’

 

18) How you can encode and decode URL in PHP?

urlencode() and urldecode is used to encrypt and decrypt the url.

 

19) How can PHP and JavaScript works?

PHP is a server side language whereas JavaScript is a client side language. But both interact with each other and work to produce useful code. JavaScript code can be written side PHP code as well as PHP code can also be written and values can be passed from PHP to JavaScript if the page has .php extension.

 

20) What do PHP need for image manipulation?

PHP has a special library for image manipulation called GD library. Its functions can be used to manipulate the image.