PHP Interviewquestions PDF: Umar Farooque Khan
PHP Interviewquestions PDF: Umar Farooque Khan
Created By:
Umar Farooque Khan
1
Copyright © pTutorial · All Rights Reserved
PHP Interview Questions For Fresher
There are some difference between GET and POST method 1. When we use
GET method requested data show in URL while when we use post method
request data does not show in the URL. 2. Post method is more secure than get
method.
Echo () and print () are not functions but language constructs in PHP. They are
both used to deliver strings as output. The main difference is print deliver only
one string as output while echo statement deliver one or more string as output.
One difference is echo is faster than print.
3
Copyright © pTutorial · All Rights Reserved
Q:-11. What are the differences between require and include function?
Both include and require function are used for including file into a current script.
The main difference is, require function will produce fatal error and stop execution
of script, as the name suggests this file is required for execution of this script.
While include function will only produce Warning and continue the script.
The include function is used in PHP when you want to include a file within the
current script. It takes only one argument.
Example
You can put your include function within the loop but in case of include_once it
will display only once.
4
Copyright © pTutorial · All Rights Reserved
Q:-14. How many ways can we get the value of current session id?
There are only one way to get value of current session id that is, session_id()
function returns the current session id.
We use setcookies() function to set and destroy the cookies by using this function
we can set and destroy the PHP cookies.
For set cookies setcookie("user", "", time()+300);
For destroy cookies setcookie("user", "", time()-300);
There are lot of function available for sorting an array like Sort(), arsort(), asort(),
ksort(), natsort(), natcasesort(), rsort(), usort(), array_multisort().
Numeric Array
5
Copyright © pTutorial · All Rights Reserved
Associative Array
Multidimensional array
Header function allows sending a raw HTTP header to the client browser. The
most common usages is simply redirecting a user to elsewhere i.e. to another
URL.
Example
<?php
echo"umar";
header("Location:http://www.ptutorial.com/");
?>
Isset() function determine whether a variable has been declared and loaded with
a value by programmer. Return true if such a variable is passed to it. If not it
return false.
We can register a simple variable into a session variable by using super global
array $_session.
$_SESSION['name'] = "user";
6
Copyright © pTutorial · All Rights Reserved
Q:-22. What is the difference between --$variable and $variable--?
Q:-23 .How much data we can upload into the database (By default)?
We can get the server properties by using $_SERVER super global array.
$_SERVER['HTTP_USER_AGENT']
7
Copyright © pTutorial · All Rights Reserved
Q:-27.What is difference between mysql_fetch_array() and mysql_fetch_row()?
mysql_query is used to execute the mysql query. It accept a variable which was
the previously loaded with the query string.
8
Copyright © pTutorial · All Rights Reserved
Q:-32. What are the different function in sorting an array?
In PHP in_array function is used to check whether given value exist in an array
or not.
Setcookies ("name","php",time()+3600);
The difference lies with the execution of the languages. PHP is a server side
scripting language, that means PHP can’t interact directly with the user. Whereas,
Java Script is a client side scripting language, that is used to interact directly with
the user.
9
Copyright © pTutorial · All Rights Reserved
Q:-38. What is the difference bitweeb mysql_fetch_array() and mysql_fetch_asoc()?
Header function is used to redirect from one webpage to another webpage Eg:
header("Location:uk.html");
Q:-41. In PHP 5 class, what are the three different visibility keywords of a property of
the method?
It is used to determine whether a given variable is set or not. That means giving
variable have a value or not.
10
Copyright © pTutorial · All Rights Reserved
Q:-43. In how many ways we can retrieve the data from MySql database using PHP?
Q:-44. How can we get the second of the current time using date function?
Date(‘s’);
Unlink deletes the given file from the file system while unset makes a variable
undefined means delete the variable value.
$_SESSION[‘name’]="Umar";
Index.php is the default name of the home page in a PHP based website.
11
Copyright © pTutorial · All Rights Reserved
Q:-48. What is use of count() function in PHP?
define("PI", "3.141592");
$x ="5 Coin"
$a=$a+20;
Echo $a;
Output : 15
12
Copyright © pTutorial · All Rights Reserved
Q:-54. What is the use of rand() function in PHP?
We use $_REQUEST super global array in PHP to collect the data value from
$_GET, $_POST and $_COOKIES variable.
Echo1<2;
Output: 1
Q:-59. Give the some example of the super global array in PHP?
13
Copyright © pTutorial · All Rights Reserved
Q:-60. How would you determine the size of a file in PHP?
14
Copyright © pTutorial · All Rights Reserved