PHP is a general-purpose programming language and it was designed originally for web development. Through PHP, dynamic page content can be generated and it can encrypt data as well. Acronym of PHP is Hypertext Preprocessor. It can run on several platforms such as Windows, Mac OS, Linux, etc.
Take advanced PHP course in Kolkata to get complete knowledge.
In the I.T sector, PHP is very popular and there are a lot of job opportunities. This article will help to prepare for PHP interview.
Some PHP training institute in Kolkata prepare their students for the interviews as well. Here are some questions which are generally asked in an interview by the employer.
1) What do you know about PHP?
PHP is commonly used for creating dynamic web applications and it is a server-side scripting language. There are some PHP’s code framework like Laravel, Cake PHP, Codeigniter, Zend, etc. WordPress, Joomla and Drupal are used for content management systems. PHP can be downloaded free and PHP scripts are executed on the server.
2) In PHP, what is the role of “echo”?
Echo is one of the basic way to get output and it is used to print a data in the web page. Echo has no return value like print.
3) Differentiate between the require() and include() functions.
The main difference require() and include() is that require will only make a fatal error (E_COMPILE_ERROR) and the script will stop however, include() will only make a warning (E_WARNING) but the script will not stop. Though, their statements are alike.
4) How can a file be included to a PHP page?
The file can be included by using include() or require() function with file path as its parameter.
5) What does PEAR means?
Abbreviation of PEAR is PHP Extension and Application Repository and it extends PHP, for web developer provides a high level of programming.
6) Differentiate between unlink() and unset().
In PHP, unlink() is used in file management whereas unset() is used for array and variable.
To destroy a file, unlike() is used and to destroy a variable unset() is used.
7) PHP looks like which programming language?
Perl and C is similar to PHP syntax.
8) What is the most common and the correct way to start and finish a PHP block of code?
The most common and the correct way to start and finish a PHP block of code are as follows:
9) Differentiate between POST and GET methods?
POST is much safe method than GET. Through POST method a large amount of data can be transferred and 1024 bytes can be send through GET.
10) In PHP, how is it possible to cast types?
To cast types, the name of the output type should be specified in the parentheses before the variable as shown below:
a) * (int), (integer) – cast to integer
b) * (float), (double), (real) – cast to float
c) * (array) – cast to array
d) * (bool), (boolean) – cast to boolean
e) * (object) – cast to object
f) * (string) – cast to string
11) In PHP, what is the default cookie?
The default session is until the closing of the browser.
12) Using PHP, how can we recover the data in the result set of MySQL?
The data in the result set of MySQL can be recovered in four ways which are as following:
a) Retrieve a result row as an associate array- mysql_fetch_assoc
b) Retrieve a result row as an object- mysql_fetch_row
c) Retrieve a result row as an enumerated array- mysql_fetch_row
d) Retrieve a result row as numeric way, associate way or both- mysql_fetch_array
13) In PHP, what are the three classes of error that can happen?
The three classes of error that can happen in PHP are as follows:
a) Fatal errors (critical errors)
b) Warnings (serious error)
c) Notices (non-critical)
14) How can a MySQL table be repaired?
The syntax used in repairing a MySQL table are as follows:
a) REPAIR TABLE tablename QUICK
b) REPAIR TABLE tablename EXTENDED
c) REPAIR TABLE tablename
15) Difference between characters /034 and /x34.
The difference between /034 and /x34 is that /034 is octal 34 and /x34 is hex 34.
16) Differentiate between PHP4 and PHP5
The differences between PHP4 and PHP5 is that OOPs concept is not supported by PHP4 and it uses Zend Engine 1. But in PHP5, OOPs concept is supported and it uses Zend Engine 2.
17) Mention some of the PHP array functions.
In PHP, there are many array functions which are follows:
a) array()
b) array_chunk()
c) array_reverse()
d) array_search()
e) array_change_key_case()
f) array_intersect()
g) sort()
h) count()
18) Mention some of the PHP string functions.
Some of the PHP string functions are as follows:
a) strtoupper()
b) strtolower()
c) strlen()
d) strrev()
e) ucwords()
f) ucfirst()
g) lcfirst()
19) In PHP, name the different loops?
The different loops in PHP are as follows:
a) for
b) while
c) do-while
d) for each.
20) How files can be read in PHP?
Various functions to read data from file is provided in PHP. There are several functions which allows us to read all file data, read data character by character and read data line by line.
Some of the functions are as follows:
a) fread() – all file data can be read
b) fget() – single line can be read from the file.
c) fgetc() – character by character can be read.
Conclusion:
These were 15 commonly questions asked in a PHP interview. From this, the candidate can get an idea about the questions asked in an interview. PHP is very popular and it is in the industry from many years. Therefore, this could a good career option who has interest in technology industry. To be a PHP expert, learn PHP course in Kolkata from the best PHP training institute in Kolkata.