SlideShare a Scribd company logo
1 of 16
PHP Interview Questions
Created by – Zuan Education
www.zuaneducation.com
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.
www.zuaneducation.com
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 <?= and ?>.
4. Describe which programming language does PHP parallel to?
The PHP syntax relates Perl and C.
5. How to create a MySQL connection?
mysql_connect(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.
www.zuaneducation.com
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 :
<?php [ — PHP code—- ] ?> and <? [— PHP code —] ?>
14. What is a numeric array?
Numeric array − An array with a numeric index. The values are stored and accessed in a linear
fashion.
www.zuaneducation.com
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.’
www.zuaneducation.com
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 can’t be enlarged and a final method
can’t 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 declared.
www.zuaneducation.com
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.
www.zuaneducation.com
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.
www.zuaneducation.com
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() can’t
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. What’s 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’);
www.zuaneducation.com
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 $_COOKIE[“user”]
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.
www.zuaneducation.com
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: <input type=button
value=”SUBMIT” onClick=”document.form.submit()”>
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.
www.zuaneducation.com
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.
www.zuaneducation.com
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 function.
www.zuaneducation.com
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 $_FILES[‘file’][‘size’] 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.
www.zuaneducation.com
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.
<!–?php $database = mysql_connect(“HOST”, “USER_NAME”, “PASSWORD”);
mysql_select_db(“DATABASE_NAME”,$database); ?–>
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.
www.zuaneducation.com
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");
www.zuaneducation.com

More Related Content

What's hot

Php interview questions
Php interview questionsPhp interview questions
Php interview questionssekar c
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answerssheibansari
 
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01Tekblink Jeeten
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questionsRohit Singh
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
8 most expected java interview questions
8 most expected java interview questions8 most expected java interview questions
8 most expected java interview questionsPoonam Kherde
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unitgowher172236
 
Java interview-questions-and-answers
Java interview-questions-and-answersJava interview-questions-and-answers
Java interview-questions-and-answersbestonlinetrainers
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 iimjobs and hirist
 
Java j2ee interview_questions
Java j2ee interview_questionsJava j2ee interview_questions
Java j2ee interview_questionsppratik86
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersWhizlabs
 
MetaCPAN, Mojolicious and OpenAPI
MetaCPAN, Mojolicious and OpenAPIMetaCPAN, Mojolicious and OpenAPI
MetaCPAN, Mojolicious and OpenAPIShawn Sorichetti
 
Java interview questions
Java interview questionsJava interview questions
Java interview questionsSoba Arjun
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabusPapitha Velumani
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questionssatish reddy
 

What's hot (20)

Php interview questions
Php interview questionsPhp interview questions
Php interview questions
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answers
 
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
Top 100-php-interview-questions-and-answers-are-below-120816023558-phpapp01
 
Best interview questions
Best interview questionsBest interview questions
Best interview questions
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questions
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
8 most expected java interview questions
8 most expected java interview questions8 most expected java interview questions
8 most expected java interview questions
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Java interview-questions-and-answers
Java interview-questions-and-answersJava interview-questions-and-answers
Java interview-questions-and-answers
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
 
Java j2ee interview_questions
Java j2ee interview_questionsJava j2ee interview_questions
Java j2ee interview_questions
 
Oss questions
Oss questionsOss questions
Oss questions
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed Answers
 
MetaCPAN, Mojolicious and OpenAPI
MetaCPAN, Mojolicious and OpenAPIMetaCPAN, Mojolicious and OpenAPI
MetaCPAN, Mojolicious and OpenAPI
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
 
Zend Framework Workshop
Zend Framework WorkshopZend Framework Workshop
Zend Framework Workshop
 
Android interview questions
Android interview questionsAndroid interview questions
Android interview questions
 

Similar to PHP Interview Questions for Freshers 2018

Similar to PHP Interview Questions for Freshers 2018 (20)

Php interview questions
Php interview questionsPhp interview questions
Php interview questions
 
php questions
php questions php questions
php questions
 
Php&amp;yii2
Php&amp;yii2Php&amp;yii2
Php&amp;yii2
 
PHP Training In Chandigarh
PHP Training In ChandigarhPHP Training In Chandigarh
PHP Training In Chandigarh
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
 
Php interview questions
Php interview questionsPhp interview questions
Php interview questions
 
Php
PhpPhp
Php
 
Unit 1
Unit 1Unit 1
Unit 1
 
How PHP works
How PHP works How PHP works
How PHP works
 
Php interview questions with answer
Php interview questions with answerPhp interview questions with answer
Php interview questions with answer
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
web design and development.docx
web design and development.docxweb design and development.docx
web design and development.docx
 
Php tutorial(w3schools)
Php tutorial(w3schools)Php tutorial(w3schools)
Php tutorial(w3schools)
 
Php tutorialw3schools
Php tutorialw3schoolsPhp tutorialw3schools
Php tutorialw3schools
 
PHP Training In Chandigarh
PHP Training In ChandigarhPHP Training In Chandigarh
PHP Training In Chandigarh
 
PHP Training In Chandigarh1.pdf
PHP Training In Chandigarh1.pdfPHP Training In Chandigarh1.pdf
PHP Training In Chandigarh1.pdf
 
Report.docx
Report.docxReport.docx
Report.docx
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
Guidelines php 8 gig
Guidelines php 8 gigGuidelines php 8 gig
Guidelines php 8 gig
 
Php Framework
Php FrameworkPhp Framework
Php Framework
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

PHP Interview Questions for Freshers 2018

  • 1. PHP Interview Questions Created by – Zuan Education www.zuaneducation.com
  • 2. 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. www.zuaneducation.com
  • 3. 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 <?= and ?>. 4. Describe which programming language does PHP parallel to? The PHP syntax relates Perl and C. 5. How to create a MySQL connection? mysql_connect(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. www.zuaneducation.com
  • 4. 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 : <?php [ — PHP code—- ] ?> and <? [— PHP code —] ?> 14. What is a numeric array? Numeric array − An array with a numeric index. The values are stored and accessed in a linear fashion. www.zuaneducation.com
  • 5. 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.’ www.zuaneducation.com
  • 6. 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 can’t be enlarged and a final method can’t 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 declared. www.zuaneducation.com
  • 7. 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. www.zuaneducation.com
  • 8. 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. www.zuaneducation.com
  • 9. 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() can’t 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. What’s 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’); www.zuaneducation.com
  • 10. 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 $_COOKIE[“user”] 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. www.zuaneducation.com
  • 11. 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: <input type=button value=”SUBMIT” onClick=”document.form.submit()”> 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. www.zuaneducation.com
  • 12. 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. www.zuaneducation.com
  • 13. 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 function. www.zuaneducation.com
  • 14. 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 $_FILES[‘file’][‘size’] 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. www.zuaneducation.com
  • 15. 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. <!–?php $database = mysql_connect(“HOST”, “USER_NAME”, “PASSWORD”); mysql_select_db(“DATABASE_NAME”,$database); ?–> 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. www.zuaneducation.com
  • 16. 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"); www.zuaneducation.com