php interview questions answers - 100+ PHP Interview Questions and Answers

100+ PHP Interview Questions and Answers

Posted on

php interview questions answers - 100+ PHP Interview Questions and Answers

100+ PHP Interview Questions and Solutions

We offer the essential php interview questions and solutions for freshers and expertise. Technical and logical Php interview questions solutions.

1. What’s PHP?

PHP stands for “Hypertext Preprocessor”. PHP is a server-side scripting language. It’s a highly effective device for making dynamic and interactive Net pages. Php is an interpreted language. It is usually an object oriented programming language like java, C-sharp and so forth.

2. Who is called the daddy of PHP?

Rasmus Lerdorf.

3. What was the outdated identify of PHP?

Private Residence Web page.

4. What’s the identify of scripting engine in PHP?

The scripting engine that powers PHP is named Zend Engine 2.

5. Clarify the distinction between PHP4 and PHP5.

PHP4 doesn’t assist oops idea and makes use of Zend Engine 1.

PHP5 helps oops idea and makes use of Zend Engine 2.

6. Listing a few of the options of PHP7.

  • Scalar sort declarations
  • Return sort declarations
  • Null coalescing operator (??)
  • Spaceship operator
  • Fixed arrays utilizing outline()
  • Nameless lessons
  • Closure::name technique
  • Group use declaration
  • Generator return expressions
  • Generator delegation
  • House ship operator

7. What’s the distinction between $message and $$message?

  • $message shops variable information whereas $$message is used to retailer variable of variables.
  • $message shops fastened information whereas the information saved in $$message could also be modified dynamically.

8. What’s PEAR in PHP?

PEAR is a framework and repository for reusable PHP parts. PEAR stands for PHP Extension and Utility Repository. It accommodates all forms of PHP code snippets and libraries.

It additionally supplies a command line interface to put in “packages” mechanically.

9. How do you execute a PHP script from the command line?

Simply use the PHP command line interface (CLI) and specify the file identify of the script to be executed as follows:

php script.php

10. Methods to run the interactive PHP shell from the command line interface?

Simply use the PHP CLI program with the choice -a as follows:

php -a

11. What are the favored Content material Administration Methods (CMS) in PHP?

  • WordPress
  • Joomla
  • Magento
  • Drupal and so forth.

12. Distinction b/w static and dynamic web sites?

In static web sites, content material can’t be modified after working the script. You possibly can’t change something within the web site. It’s predefined.

In dynamic web sites, a content material of script might be modified on the runtime. Its content material is regenerated each time a consumer go to or reload. Google, Yahoo, and each search engine is the instance of a dynamic web site.

13. What are the favored frameworks in PHP?

  • CakePHP
  • CodeIgniter
  • Yii 2
  • Symfony
  • Zend Framework and so forth.

14. Which programming language does PHP resemble?

PHP has borrowed its syntax from Perl and C.

15. What’s “echo” in PHP?

PHP echo output a number of string. It’s a language assemble not a perform. So using parentheses shouldn’t be required. However if you wish to go multiple parameter to echo, use of parentheses is required.

The echo assertion can be utilized with or with out parentheses: echo or echo()

16. What’s “print” in PHP?

PHP print output a string. It’s a language assemble not a perform. So using parentheses shouldn’t be required with the argument checklist. Not like echo, it at all times returns 1.

The print assertion can be utilized with or with out parentheses: print or print().

17. What’s the distinction between “echo” and “print” in PHP?

Echo can output a number of string however print can solely output one string and at all times returns 1.

Echo is quicker than print as a result of it doesn’t return any worth.

18. How is a variable declared in PHP?

PHP variable is a reputation of a reminiscence location that holds information. It’s a non permanent storage.

In PHP, a variable is asserted utilizing $ signal adopted by a variable identify.

Syntax of declaring a variable in PHP is given under:

$variablename=worth;

19. Clarify PHP variable size argument perform

PHP helps variable size argument perform. It means you may go 0, 1 or n variety of arguments within the perform. To do that, it is advisable use 3 ellipses (dots) earlier than the argument identify. The 3 dot idea is carried out for variable size argument since PHP 5.6.

20. Clarify the PHP variable size argument perform.

PHP helps variable size argument perform. It means you may go 0, 1 or n variety of arguments.

21. What’s the array in PHP?

Array is used to retailer a number of values in a single worth. In PHP, it orders maps of pairs of keys and values. It shops the gathering of a knowledge sort.

22. What number of forms of the array are there in PHP?

There are three forms of the array in PHP:

  • Listed array
  • Associative array
  • Multidimensional array

23. Clarify a few of the PHP array capabilities?

There are various array capabilities in PHP:

  • array()
  • array_change_key_case()
  • array_chunk()
  • rely()
  • type()
  • array_reverse()
  • array_search()
  • array_intersect()

24. What’s the distinction between listed and associative array?

The listed array holds parts in an listed type which is represented by quantity ranging from Zero and incremented by 1. For instance:

The associative array holds parts with identify. For instance:

25. Methods to get the size of string?

The strlen() perform is used to get the size of a string.

26. Clarify a few of the PHP string capabilities?

There are various array capabilities in PHP:

  • strtolower()
  • strtoupper()
  • ucfirst()
  • lcfirst()
  • ucwords()
  • strrev()
  • strlen() and so forth.

27. What are the methods to outline a relentless in PHP?

PHP constants are identify or identifier that may’t be modified throughout execution of the script. PHP constants are outlined in two methods:

  • Utilizing outline() perform
  • Utilizing const() perform

28. What are magic constants in PHP?

PHP magic constants are predefined constants which change on the premise of their use. They begin with a double underscore (__) and finish with a double underscore (__).

29. What number of information sorts are there in PHP?

PHP information sorts are used to carry various kinds of information or values. There are 8 primitive information sorts that are additional categorized into 3 sorts:

  • Scalar sorts
  • Compound sorts
  • Particular sorts

30. Methods to do single and multi-line remark in PHP?

PHP single line remark is finished in two methods:

Utilizing // (C++ type single line remark)
Utilizing # (Unix Shell type single line remark)
PHP multi-line remark is finished by enclosing all strains inside /* */.

31. What are the totally different loops in PHP?

For, whereas, do-while and for every.

32. What’s using rely() perform in PHP?

The PHP rely() perform is used to rely complete parts within the array, or one thing an object.

33. What’s using header() perform in PHP?

The header() perform is used to ship a uncooked HTTP header to a consumer. It have to be known as earlier than sending the precise output. For instance, you may’t print any HTML ingredient earlier than utilizing this perform.

34. What does isset() perform?

The isset() perform checks if the variable is outlined and never null.

35. Clarify PHP parameterized capabilities.

PHP parameterized capabilities are capabilities with parameters. You possibly can go any variety of parameters inside a perform. These handed parameters act as variables inside your perform. They’re specified contained in the parentheses, after the perform identify. Output relies upon upon dynamic values handed as parameters into the perform.