PHP Interview Questions for Freshers - PowerPoint PPT Presentation

View by Category
About This Presentation

PHP Interview Questions for Freshers


Zuan Education provides real-time PHP training from beginner to advanced level programs with project-based training. The PHP course syllabus is hand-crafted by industry experts, and we adhere to the syllabus with latest technologies based on current industry demands across various disciplines. Our PHP training course gives the required knowledge to design and create dynamic, database-driven web applications with in-depth training on PHP right from the fundamentals. – PowerPoint PPT presentation

Number of Views:3


Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: PHP Interview Questions for Freshers

PHP Interview Questions
Created by Zuan Education
Why should you read this article? We would
advise you read this blog because it provides an
insight of the following A significant PHP
Interview Questions and Answers which will be
very helpful for those who are trying for a job
in web development. Customized PHP Interview
Questions for Freshers as well as it will be
useful for experienced candidates too.
Generally required technical PHP Interview
Questions and answers in 2018.
1. What is PHP? PHP is a widely-used,
open-source server-side scripting language. PHP
is an acronym for PHP Hypertext Preprocessor.
It allows the developers to develop dynamic web
applications. PHP has various frameworks and CMS
for developing dynamic and interactive
websites. 2. What types of loops exist in
PHP? for, while, do while and foreach. 3. How
do you display the output directly to the
browser? To display the output directly to the
browser, I will use the special tags lt? and
?gt. 4. Describe which programming language does
PHP parallel to? The PHP syntax relates Perl and
C. 5. How to create a MySQL connection? mysql_co
nnect(servername,username,password) 6. How to
select a database? mysql_select_db(db_name) 7.
What is PEAR? PEAR means PHP Extension and
Application Repository. It is a framework and
distribution system for reusable PHP components.
It extends PHP and gives a higher level of
programming for all web developers. PEAR is
divided into three different classes that are
PEAR Core Components, PEAR Packages, and PECL
Packages. The PEAR Packages include functionality
giving for authentication, networking, and file
system features and tools for working with HTML
and XML templates.
8. What is the use of ksort in php? In PHP,
Ksort has used to sort an array by key in reverse
order. 9. What are the data types of
PHP? Integers, Doubles, Booleans, Arrays,
Objects, NULL, Strings. 10. Which PHP version is
actually used today? Nowadays, PHP 7 is the
actually used version. PHP Interview
Tip During the interview of a potential
candidate, I am aiming to understand how updated
they are Click To Tweet 11. What is NULL? NULL
is a particular type which contains only one
value NULL. If you need any variable to set
NULL, just assign it. 12. What is the use of
Constant Function? A constant function is used
to return the constant value. 13. What is the
correct way to start and complete a PHP block of
code? There is the two most common and correct
ways to start and complete a PHP script. That is
lt?php PHP code- ?gt and lt? PHP
code ?gt 14. What is a numeric
array? Numeric array - An array with a numeric
index. The values are stored and accessed in a
linear fashion.
15. Does PHP support multiple inheritances? PHP
supports only single level of inheritance. A
class can be inherited from a single class using
the keyword extended. 16. Describe what is the
major difference between PHP 4 and PHP 5? PHP 5
is an upgrade version of PHP 4. PHP 5 offers many
extra OOPs features. It introduces new functions
which are not found in PHP4. In PHP 5, you have
to name your constructors. In PHP 5, Class can
be declared as Abstract. PHP 5 introduced a
special function which is __autoload(). In PHP
5, Class or method can be declared as Final. In
PHP 5, Magic methods are introduced such as
__call, __get, __set and __toString. In PHP 5,
exceptions'(exception errors) has
introduced. In PHP 5, interfaces are
introduced. 17. What are tags used? They allow
making the result of the expression between the
tags directly to the browser response. 18. What
is the difference between explode() and split()
functions? Split function splits a string into
array by regular expression. Explode splits a
string into array by string. 19. Is PHP supports
multiple inheritance? The PHP comprises only
single inheritance which means that a class could
be enlarged from just one single class utilizing
the keyword extended.
20. What is the use of count function in
MySQL? count() function is used for fetching the
total number records in a table. 21. How to send
a mail in PHP? You can send an e-mail in PHP
with mail() function or SMTP details. 22.
Explain what the meaning of a final class and a
final method is? final is initiated in PHP 5.
Final class implies that this class cant be
enlarged and a final method cant be
overridden. 23. How can you break PHP script? I
can use exit() function for that. 24. What is
the default page in web server? Most of the
times it will be index page. 25. Explain how a
comparison of objects done in PHP 5 is? I can
use the operator to test two objects are
mentioned from the corresponding class and have
equal attributes and similar values. I can test
if two objects are referring to the same instance
of the corresponding class by the control of the
identity operator . 26. What are the
different types of errors in PHP? There are 4
basically types of error in PHP. Parse Error
Commonly caused due to syntax mistakes in
codes. Fatal Error These are basically runtime
errors which are caused when you try to access
what cannot be done. Warning Error This error
occurs when you try to include a file that is not
present. Notice Error This error occurs when
you try to utilize a variable that has not been
27. What is session and why do we use it? A
session is a super global variable that preserves
data across subsequent pages. Session uniquely
defines all users with a session ID. So it
supports building a customized web application
where user tracking is required. 28. Describe
how PHP and HTML can interact? Also, it is
possible to make HTML into PHP scripts, and it is
possible to transfer information from HTML to
PHP. 29. Explain which type of operation is
required when passing values into an URL? To
pass values by an URL, then you require to encode
and to decode them applying urlencode () and
htmlspecialchars(). 30. What is cookie and why
do we use it? A cookie is a small piece of
information stored in a client browser. It is a
technique utilized to identify a user using the
information stored in their browser. Utilizing
PHP, we can both set and get COOKIE. 31. What
function do we use to find length of string, and
length of array? For finding a length of string
we apply strlen() function and for array we use
count() function. 32. Describe how PHP and
Javascript can interact? The PHP and Javascript
could not directly interact because PHP is a
server-side scripting language and Javascript is
a client-side scripting language. But, we can
change variables, because PHP can generate
JavaScript code to be performed by the web
browser and it is likely to pass particular
variables behind to PHP into the URL. 33. How
can we modify the value of a constant? We cannot
alter the value of a constant. 34. What is the
difference between unset() and unlink()
function? unset() function is used to destroy a
variable whereas unlink() function is used to
destroy a file.
35. Explain which is required to be able to
utilize image function? The GD library is
required to be able to do image functions. It
also helps to execute more image functions. 36.
What is the difference between ID and class in
CSS? The difference between an ID and Class is
that an ID can be utilized to identify one
element, whereas a class can be used to identify
more than one. 37. What is AJAX? AJAX
(Asynchronous JavaScript and XML) is a technique
which enables updating parts of a web page,
without reloading the entire page. Data is
exchanged asynchronously in a small amount of
data with the server. 38. What is the use of
imagetypes() function? A function imagetypes()
provides the image format and types carried by
the latest version of GD-PHP. 39. What is
jQuery? jQuery is a fast, small, and
feature-rich JavaScript library. It is an
easy-to-use API. It makes things like HTML
document traversal and manipulation, animation,
event handling and Ajax much simpler across a
more number of browsers. 40. What is the
difference between SQL and Mysql? SQL(Structured
Query Language) is a programming language created
for managing data held in a Relational Database
Management System. Mysql is an open source,
relational database management System. 41. What
is the use of echo in PHP? In PHP, echo is
used to print data on the webpage.
41. Describe what the functions to be utilized to
get the image properties (Height, Width, and
Size) are? There are three functions are used to
get image properties. That functions
are imagesy() for getting image
height. imagesx() for getting image
width. getimagesize() for getting image
size. 42. What is JOIN in MySQL? What are the
different types of join? MySQL JOINS are
utilized to retrieve data from multiple tables.
It is performed whenever two or more tables are
joined in a SQL statement. There are various
types of MySQL joins INNER JOIN, LEFT JOIN,
RIGHT JOIN and OUTER JOIN. 43. Explain how
failures in execution are worked with include()
and require() functions? There are some failures
when using functions include() and require(). If
the function require() cant access the file then
it stops with a fatal error. But, the include()
function provides a warning, and the PHP script
proceeds to perform. 44. How to include a file
to a PHP page? We can include a file utilizing
include() or require() function with file
path as its parameter. 45. Whats the difference
between include and require? If the file is not
found by require(), it will cause a fatal error
and stop the execution of the script. If the file
is not found by include(), a warning will be
issued, but execution will continue. 46.
Describe how you can display information of a
variable and readable through a human with
PHP? I can use print_r() function to display a
human-readable result. 47. How to declare an
array in PHP? Ex var arr array(apple,
grape, lemon)
48. What is the use of print in PHP? It is
not actually a real function, it is a language
construct. So you can utilize without parentheses
with its argument list. 49. Explain the PHP
error what means Parse error in PHP unexpected
T_variable at line x? This error is a PHP
syntax error which is revealing that trouble at
the line x stops parsing and performing the
program. 50. How to Retrieve a Cookie
Value? Ex echo _COOKIEuser 51. What is
SQL injection? SQL injection is a malicious code
injection technique that might destroy your
database. It exploiting SQL vulnerabilities in
Web applications. It is one of the most common
web hacking techniques. 52. What should you do
to be capable to export data into an Excel
file? The most comprehensive way is to take data
into a format supported by Excel. For example, it
is likely to write a .csv file, to choose for
instance comma as a separator between fields and
then to open the file in Excel. 53. Describe
what the default session time in PHP is? In PHP.
the default session time is until the closing of
the browser 54. How to destroy a cookie in
PHP? There is not a way to directly delete a
cookie. Just use the setcookie function with the
expiration date in the past, to trigger the
removal mechanism in your web browser.
55. How to enlarge the execution time of a PHP
script? It is possible to enlarge the execution
time of a PHP script by utilizing the
set_time_limit function. It enables to enlarge
the execution time of a PHP script. 56. Explain
how you can pass the variable by the navigation
between the pages in PHP? I can pass the
variable in the navigation by applying cookies,
sessions or hidden form fields. 57. How to
submit a form with a dedicated button in
PHP? The document.form.submit() function helps
to submit the form. For example ltinput
typebutton valueSUBMIT onClickdocument.form.
submit()gt 58. Explain the difference between
the functions stristr() and strstr() in
PHP? strstr() and stristr both are used to find
the first occurrence of the string. stristr( ) is
case insensitive, and it is an identical to
superglobal() except that it is case insensitive.
The strstr() Find first occurrence of a
string. 59. Explain how you can define whether a
variable is set? I can use a boolean function.
It is set defines if a variable is set and is not
NULL. 60. Explain how to parse a configuration
file? It is possible to parse a configuration
file by using the parse_ini_file() function. It
enables us to load in the ini file defined in the
filename and returns the settings in it in an
associative array. The time you run your script
already processes it. 61. What is the use of
goto statement? Php also supports operator goto
statement which is the operator of
unconditional transition. It can be placed to
support jumping inside the PHP program. It
applied to go into another area of the code. 62.
Explain unset() function? The function unset()
is used for variable management. It will generate
a variable undefined.
63. What function is used to escape data before
storing into the database? The function
addslashes allows us to escape data before
storing inside the database. 64. How do you
remove escape characters from a string? I can
use stripslashes function. It allows us to remove
the escape characters before apostrophes in a
string. 65. Explain how can you automatically
escape incoming data? I can allow the Magic
quotes entry in the configuration file of PHP. I
will be helping you to escape incoming data. 66.
Explain the get_magic_quotes_gpc()
function? get_magic_quotes_gpc() function shows
us whether the magic quotes is switched on or
not. 67. How do you remove the HTML tags from
data in PHP? I can use strip_tags() function to
remove HTML tags. It allows us to remove a string
from the HTML tags. 68. Explain how you can
determine a variable accessible in functions of a
PHP script? It is possible by utilizing the
global keyword. 69. Describe how it is possible
to return a value from a function in PHP? It is
possible to return a value by using the
instruction return value. 70. Explain which
cryptographic extension present generation and
verification of digital signatures? The
extension PHP-OpenSSL gives some cryptographic
operations including the generation and
verification of digital signatures.
71. Explain how you can pass a variable by
reference? I can use an ampersand in front of
it, as follows var1 var2. It will help to
pass a variable. 72. Describe how it is possible
to cast types in PHP? It has to be described in
parentheses before the variable which is to be
cast as follows (string) cast to string
(int), (integer) cast to integer (array)
cast to an array (float), (double), (real)
cast to float (bool), (boolean) cast to
boolean (object) cast to object (float),
(double), (real) cast to float 73. Describe
when a conditional statement is ended with
endif? A conditional statement will end when the
original if was followed by and then the code
block without any braces. 74. Explain how the
ternary conditional operator is applied in
PHP? The ternary operator is a set of three
expressions a condition, and two operands
defining what instruction need to be executed
when the named condition is true or false like
below Expression_1? Expression_2
Expression_3 75. What is the use of
func_num_args() function? In PHP, the
func_num_args() function is utilized to provide
the number of parameters passed inside a
76. What is rand() function in PHP? The rand()
function is used to generate random numbers. 77.
Explain the difference between __sleep and
__wakeup method in PHP? The __sleep method
returns the array of all the variables that
should be saved, while __wakeup method retrieves
them. 78. Describe a session? The definition of
a session is a logical object allowing us to
store temporary data over various PHP pages. 79.
Explain how to initiate a session in
PHP? session_start() function allows us to
activating a session. 80. Explain how is it
possible to create a session id? Generating a
session id through cookies or URL parameters is
possible. 81. What are MAGIC Constants in
PHP? PHP gives a large number of predefined
constants to any script which it runs known as
magic constants. 82. Explain the meaning of a
Persistent Cookie in PHP? It is also called as a
Permanent cookie. A persistent cookie is
permanently saved in a cookie file on the
computer. 83. How to know uploaded file
size? Using _FILESfilesize statement to
know uploaded filesize in PHP. 84. What is
GLOBALS? The GLOBALS is a PHP superglobal
variable. It can be utilized instead of a global
keyword to access variables from global scope.
85. What is _SERVER? The _SERVER is an array
adding information created by the web server. For
example headers, paths, and script
locations. 86. What is _FILES? The _FILES is
an associative array created for items sent to
the current script through the HTTP POST
method. 87. What is _ENV? In PHP, _ENV is
used to return the environment variables from the
web server. It is an associative array of
variables sent to the latest PHP script through
the environment method. To set real environment
variables, you need to use putenv(). 88. What is
the use of file_get_contents() function? The
function file_get_contents() is used to read a
file and store it in a string variable. 89.
Explain how you can connect to a MySQL database
from a PHP script? To connect a MySQL database,
i can use mysql_connect() function. lt!?php
database mysql_connect(HOST, USER_NAME,
PASSWORD) mysql_select_db(DATABASE_NAME,data
base) ?gt 90. Explain how it is possible to
know the number of rows returned in the result
set? It is possible to know using
mysql_num_rows() function. It returns the number
of rows in the result set. 91. Explain which
function provides us the number of modified
entries by a query? The function
mysql_affected_rows() returns the number of
entries modified by an SQL query.
92. Explain the difference between
mysql_fetch_object() and mysql_fetch_array() in
PHP? This will provide access to the data
through the field names. In PHP, the function
mysql_fetch_object() will get the first single
matching record where mysql_fetch_array() will
get all matching records from the table in an
array. 93. How can you verify the value of a
provided variable is a number? I can use
is_numeric() function to verify whether it is a
number or not. 94. How can you examine the value
of a given variable is alphanumeric? I can use
ctype_alnum function to verify whether it is an
alphanumeric value or not. 95. How do you verify
if a provided variable is empty? I can verify if
a given variable is empty by using empty()
function. 96. Explain the unlink()
function? The function unlink() is applied for
file system handling. It just deletes the file
given as entry. 97. When did sessions end? The
sessions will automatically end when the PHP
script stops executing. However, it can be
manually finished by utilizing the
session_write_close(). 98. Explain how you can
pass a variable by reference? I can use an
ampersand in front of it, as follows var1
var2. It will help to pass a variable. 99.
Describe when a conditional statement is ended
with endif? A conditional statement will end
when the original if was followed by and then
the code block without any braces. 100. How can
we get second of the current time using date
function? second date("s")