81+ PHP Interview Questions

81+ PHP Interview Questions

PHP Interview Questions

1) What is PHP? 

PHP represents Hypertext Preprocessor. It is an open source server-side scripting language which is broadly utilized for web advancement. It underpins numerous databases like MySQL, Oracle, Sybase, Solid, PostgreSQL, conventional ODBC and so forth.

2) What is PEAR in PHP? 

PEAR is a structure and vault for reusable PHP parts. PEAR represents PHP Extension and Application Repository. It contains a wide range of PHP code pieces and libraries.

It additionally gives a direction line interface to introduce "bundles" naturally.

3) Who is known as the dad of PHP? 

Rasmus Lerdorf

4) What was the old name of PHP? 

Individual Home Page.

5) Explain the distinction b/w static and dynamic sites? 

In static sites, content can't be changed subsequent to running the content. You can't transform anything in the site. It is predefined.

In powerful sites, substance of content can be changed at the run time. Its substance is recovered each time a client visit or reload. Google, yippee and each internet searcher is the case of dynamic site.

6) What is the name of scripting motor in PHP? 

The scripting motor that powers PHP is called Zend Engine 2.

7) Explain the distinction somewhere in the range of PHP4 and PHP5. 

PHP4 doesn't bolster oh no idea and utilizations Zend Engine 1.

PHP5 underpins oh no idea and utilizations Zend Engine 2.

8) What are the well known Content Management Systems (CMS) in PHP? 

WordPress

Joomla

Magento

Drupal and so on.

9) What are the well known structures in PHP? 

CakePHP

CodeIgniter

Yii 2

Symfony

Zend Framework and so on.

10) Which programming language does PHP take after to? 

PHP has acquired its punctuation from Perl and C.

11) List a portion of the highlights of PHP7. 

Scalar sort revelations

Return type revelations

Invalid mixing administrator (??)

Spaceship administrator

Consistent exhibits utilizing characterize()

Mysterious classes

Closure::call strategy

Gathering use assertion

Generator return articulations

Generator appointment

Space send administrator

12) What is "reverberation" in PHP? 

PHP reverberation yield at least one string. It is a language build not a capacity. So utilization of enclosures isn't required. In any case, in the event that you need to pass more than one parameter to resound, utilization of enclosures is required.

Language structure:

void reverberation ( string $arg1 [, string $... ] ) 

13) What is "print" in PHP? 

PHP print yield a string. It is a language build not a capacity. So utilization of brackets isn't required with the contention list. In contrast to resound, it generally returns 1.

Language structure:

int print ( string $arg) 

14) What is the distinction among "reverberation" and "print" in PHP? 

Reverberation can yield at least one string yet print can just yield one string and dependably returns 1.

Reverberation is quicker than print since it doesn't restore any esteem.

15) How a variable is proclaimed in PHP? 

PHP variable is a name of memory area that holds information. It is a brief stockpiling.

Grammar:

$variableName=value;

16) What is the distinction among $message and $$message? 

$message stores variable information while $$message is utilized to store variable of factors.

$message stores fixed information while the information put away in $$message might be changed powerfully.

17) What are the approaches to characterize a steady in PHP? 

PHP constants are name or identifier that can't be changed amid execution of the content. PHP constants are characterized in two different ways:

Utilizing characterize() work

Utilizing const() work .

18) What are enchantment constants in PHP? 

PHP enchantment constants are predefined constants which changes based on their utilization. They begin with a twofold underscore (__) and end with a twofold underscore (__).

19) what number information types are there in PHP? 

PHP information types are utilized to hold diverse kinds of information or qualities. There are 8 crude information types which are additionally arranged in 3 types:

Scalar sorts

Compound sorts

Uncommon sorts

20) How to do single and multi line remark in PHP? 

PHP single line remark is done in two different ways:

Utilizing/(C++ style single line remark)

Utilizing # (Unix Shell style single line remark)

PHP multi line remark is finished by encasing all lines inside/*/.

21) What are the distinctive circles in PHP? 

For, while, do-while and for each.

22) What is the utilization of check() work in PHP? 

The PHP tally() work is utilized to include complete components in the exhibit, or something an article.

23) What is the utilization of header() work in PHP? 

The header() work is utilized to send a crude HTTP header to a customer. It must be called before sending the genuine yield. For instance, you can't print any HTML component before utilizing this capacity.

24) What does isset() work? 

The isset() work checks if the variable is characterized and not invalid.

25) Explain PHP parameterized capacities. 

PHP parameterized capacities are capacities with parameters. You can pass any number of parameters inside a capacity. These passed parameters go about as factors inside your capacity. They are indicated inside the enclosures, after capacity name. Yield relies on unique qualities go as parameters into capacity.

26) Explain PHP variable length contention work 

PHP bolsters variable length contention work. It implies you can pass 0, 1 or n number of contentions in capacity. To do this, you have to utilize 3 circles (specks) before the contention name. The 3 spot idea is executed for variable length contention since PHP 5.6.

27) Explain PHP variable length contention work. 

PHP bolsters variable length contention work. It implies you can pass 0, 1 or n number of contentions.

28) What is the cluster in PHP? 

Cluster is utilized to store numerous qualities in single esteem. In PHP, it orders maps of sets of keys and qualities. It stores the gathering of information type.

29) what number sorts of exhibit are there in PHP? 

There are three kinds of cluster in PHP:

Filed cluster

Affiliated cluster

Multidimensional exhibit

30) Explain a portion of the PHP exhibit capacities? 

There are many cluster works in PHP:

exhibit()

array_change_key_case()

array_chunk()

tally()

sort()

array_reverse()

array_search()

array_intersect()

31) What is the distinction among listed and cooperative cluster? 

The ordered exhibit holds components in a recorded structure which is spoken to by number beginning from 0 and increased by 1. For instance:

$season=array("summer","winter","spring","autumn");

The acquainted exhibit holds components with name. For instance:

$salary=array("Sonoo"=>"350000","John"=>"450000","Kartik"=>"200000");

32) How to get the length of string? 

The strlen() work is utilized to get the length of string.

33) Explain a portion of the PHP string capacities? 

There are many cluster works in PHP:

strtolower()

strtoupper()

ucfirst()

lcfirst()

ucwords()

strrev()

strlen()

34) What are the techniques to submit structure in PHP? 

There are two techniques GET and POST.

35) How would you be able to present a structure without a submit catch? 

You can utilize JavaScript submit() capacity to present the structure without unequivocally clicking any submit catch.

36) What are the approaches to incorporate record in PHP? 

PHP enables you to incorporate document with the goal that page substance can be reused once more. There are two different ways to incorporate record in PHP.

incorporate

require

37) Differentiate among require and incorporate? 

Require and incorporate both are utilized to incorporate a record, yet in the event that document isn't found incorporate sends cautioning though require sends Fatal mistake.

38) Explain setcookie() work in PHP? 

PHP setcookie() work is utilized to set treat with HTTP reaction. When treat is set, you can get to it by $_COOKIE superglobal variable.

Sentence structure:

bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path

[, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] )

More subtleties...

39) How would you be able to recover a treat esteem?

reverberation $_COOKIE ["user"];

40) What is a session? 

PHP Engine makes a sensible article to protect information crosswise over ensuing HTTP demands, which is known as session.

Sessions for the most part store impermanent information to permit different PHP pages to offer a total practical exchange for a similar client.

Essentially, it keeps up information of a client (program).

41) What is the strategy to enlist a variable into a session? 


Session_register($ur_session_var);

?>

42) What is $_SESSION in PHP? 

PHP $_SESSION is an affiliated cluster that contains all session factors. It is utilized to set and get session variable qualities. 

43) What is PHP session_start() and session_destroy() work? 

PHP session_start() work is utilized to begin the session. It begins another or resumes the current session. It restores the current session if session is made as of now. On the off chance that session isn't accessible, it makes and returns new sessions.

44) What is the contrast among session and treat? 

The principle distinction among session and treat is that treats are put away on client's PC in the content record group while sessions are put away on the server side.

Treats can't hold different factors then again Session can hold numerous factors.

You can physically set an expiry for a treat, while session just stays dynamic as long as program is open.

45) Write punctuation to open a document in PHP? 

PHP fopen() work is utilized to open document or URL and returns asset. It acknowledges two contentions: $filename and $mode.

Sentence structure:

asset fopen ( string $filename , string $mode [, bool $use_include_path = false [, asset $context ]] )

46) How to peruse a document in PHP? 

PHP gives different capacities to peruse information from record. There are diverse capacities that enable you to peruse all document information, read information line by line and read information character by character.

PHP document read capacities are given beneath:

fread()

fgets()

fgetc()

47) How to write in a record in PHP? 

PHP fwrite() and fputs() capacities are utilized to compose information into record. To compose information into record, you have to utilize w, r+, w+, x, x+, c or c+ mode.

48) How to erase record in PHP? 

The unlink() work is utilized to erase record in PHP.

bool unlink (string $filename)

49) What is the strategy to execute a PHP content from the order line? 

You should simply run the PHP order line interface (CLI) and indicate the document name of the content to be executed as pursues.

50) How to transfer document in PHP? 

The move_uploaded_file() work is utilized to transfer document in PHP.

bool move_uploaded_file ( string $filename , string $destination )

51) How to download document in PHP? 

The readfile() work is utilized to download document in PHP.

int readfile ( string $filename )

52) How would you be able to send email in PHP? 

The mail() work is utilized to send email in PHP.

bool mail($to,$subject,$message,$header);

53) How would you interface MySQL database with PHP? 

There are two strategies to interface MySQL database with PHP. Procedural and object arranged style.

54) How to make association in PHP? 

The mysqli_connect() work is utilized to make association in PHP.

asset mysqli_connect (server, username, secret key)

55) How to make database association and question in PHP? 

Since PHP 4.3, mysql_reate_db() is censured. Presently you can utilize following 2 options.

mysqli_query()

PDO::_query()

56) How would we be able to build execution time of a PHP content? 

As a matter of course, most extreme execution time for PHP contents is set to 30 seconds. On the off chance that a content takes over 30 seconds, PHP stops the content and returns a mistake.

You can change the content run time by changing the max_execution_time order in php.ini document.

At the point when a content is called, set_time_limit work restarts the timeout counter from zero. That is to say, if default clock is set to 30 sec, and 20 sec is determined in capacity set_time_limit(), at that point content will keep running for 45 seconds. On the off chance that 0sec is indicated in this capacity, content takes boundless time.

57) What are the distinctive sorts of blunders in PHP? 

There are 3 kinds of blunder in PHP.

Notices:These are non-basic mistakes. These blunders are not showed to the clients.

Warnings:These are increasingly genuine blunders yet they don't result in content end. As a matter of course, these mistakes are shown to the client.

Lethal Errors:These are the most basic blunders. These mistakes may cause because of quick end of content.

58) How to stop the execution of PHP content? 

The leave() work is utilized to stop the execution of PHP content.

59) What are the encryption capacities in PHP? 

Sepulcher() and MD5()

60) What is htaccess in PHP? 

The .htaccess is a design document on Apache server. You can change arrangement settings utilizing mandates in Apache design documents like .htaccess and httpd.conf.

61) Explain PHP detonate() work. 

The PHP detonate() work breaks a string into a cluster.

62) Explain PHP split() work.

The PHP split() work parts string into an exhibit by ordinary articulation.

63) How would we be able to get IP address of a customer in PHP?

$_SERVER["REMOTE_ADDR"];