PHP Interview Questions Fresher

What is PHP?

PHP is a server side scripting dialect ordinarily utilized for web applications. PHP has numerous structures and cms for making websites.Even a non specialized individual can cretae destinations utilizing its CMS.WordPress,osCommerce are the famus CMS of php.It is additionally a protest arranged programming dialect like java,C-sharp etc.It is extremely eazy for learning

What is the use of "echo" in php?

It is utilized to print an information in the website page, Example: reverberate ‘Auto protection’; , The accompanying code print the content in the site page

How to include a file to a php page?

We can include a file using “include() ” or require()” function with file path as its parameter.

What's the difference between include and require?

In the event that the document is not found by require(), it will bring about a deadly blunder and stop the execution of the script. On the off chance that the record is not found by incorporate(), a notice will be issued, yet execution will proceed.

require_once(), require(), include().What is difference between them?

require() incorporates and assesses a particular record, while require_once() does that lone in the event that it has not been incorporated before (in agreement). In this way, require_once() is prescribed to utilize when you need to incorporate a record where you have a great deal of capacities for instance. Along these lines you ensure you do exclude the document more times and you won’t get the “capacity re-proclaimed” blunder.

Differences between GET and POST methods ?

We can send 1024 bytes utilizing GET strategy yet POST technique can exchange extensive measure of information and POST is the protected strategy than GET technique .

How to proclaim a cluster in php?

Eg : var $arr = array(‘apple’, ‘grape’, ‘lemon’);

What is the utilization of "print" in php?

This is not really a genuine capacity, It is a dialect build. So you can use without enclosures with its contention list.

Illustration print(‘PHP Interview questions’);

print ‘Prospective employee meet-up ‘);

What is utilization of in_array() capacity in php ?

in_array used to checks if an esteem exists in an exhibit

What is utilization of include() capacity php ?

count() is utilized to include all components a cluster, or something in a protest

Differences between GET, POST and REQUEST methods ?

GET and POST are utilized to send data from customer program to web server. In the event of GET the data is send by means of GET strategy in name/esteem combine and is URL encoded. The default GET has an utmost of 512 characters. The POST technique exchanges the data through HTTP Headers. The POST technique does not have any limitation in information size to be sent. POST is utilized for sending information safely and ASCII and double sort’s information. The $_REQUEST contains the substance of both $_GET, $_POST and $_COOKIE.

What are the different errors in PHP?

There are 4 essentially sorts of blunder.

Parse Error – Commonly brought about because of grammar mix-ups in codes e.g. missing semicolon, befuddle sections.

Fatal Error – These are essentially run time blunders which are brought about when you attempt to get to what isn’t possible. E.g. getting to a dead protest, or attempting to utilize a capacity that hasn’t been proclaimed.

Warning Error – These happens when u attempt to incorporate a record that is not present, or erase a document that is not on the server. This won’t end the script; it will give the notice and proceed with the following line of the script.

Notice Error – These mistakes happens when u attempt to utilize a variable that hasn’t been pronounced, this won’t stop the script, It will give the notice and proceed with the following line of the script.

What is session and why do we use it?

Session is a super worldwide variable that save information crosswise over resulting pages. Session interestingly characterizes every client with a session ID, so it helps making altered web application where client following is required.

What is cookie and why do we use it?

Treat is a little bit of data put away in customer program. It is a method used to recognize a client utilizing the data put away as a part of their program (if as of now went to that site) . Utilizing PHP we can both set and get COOKIE.

What is the difference between explode() and split() functions?

Both are utilized to part a string to exhibit, the fundamental contrast is that split() utilizes design for part and explode() utilizes a string. explode() is quicker than split() as it doesn’t coordinate the string in light of standard expression. Likewise split() is censured starting 5.3.0. So utilizing of this capacity is demoralized.

What is AJAX?

AJAX (Asynchronous JavaScript and XML) is a strategy which permits redesigning parts of a site page, without reloading the entire page. Information is traded nonconcurrently in little measures of information with the server.

What are the encryption techniques in PHP

MD5 PHP implements the MD5 hash algorithm using the md5 function,
eg : $encrypted_text = md5 ($msg);

mcrypt_encrypt :- string mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] );
Encrypts plaintext with given parameters

How to get the value of current session id?

session_id() function returns the session id for the current session.

What is PEAR?

PEAR is a structure and circulation framework for reusable PHP components.The extend looks to give an organized library of code, keep up a framework for conveying code and for overseeing code bundles, and advance a standard coding style.PEAR is broken into three classes: PEAR Core Components, PEAR Packages, and PECL Packages. The Core Components incorporate the base classes of PEAR and PEAR_Error, alongside database, HTTP, logging, and messaging capacities. The PEAR Packages incorporate usefulness accommodating confirmation, systems administration, and record framework highlights, and instruments for working with XML and HTML layou

Distinguish between urlencode and urldecode?

This technique is best when encode a string to utilized as a part of an inquiry part of a url. it gives back a string in which all non-alphanumeric characters aside from – _. have replece with a percentege(%) sign . the urldecode->Decodes url to encode string as any %and other symbole are unravel by the utilization of the urldecode() work

What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

Mysql_fetch_array Fetch a result row as an associative array, a numeric array, or both.
mysql_fetch_object ( resource result ) Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows
mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.