Created by Vineet Kumar Saini: Top 100 PHP Interview Questions and Answers Are Below
Created by Vineet Kumar Saini: Top 100 PHP Interview Questions and Answers Are Below
Page 1
AES_DECRYPT()
ENCODE()
DECODE()
DES_ENCRYPT()
DES_DECRYPT()
ENCRYPT()
Not available
MD5()
Not available
Not available
SHA() or SHA1()
Not available
Not available
UNCOMPRESSED_LENGTH()
Page 4
Page 6
Page 7
know
know
know
know
the
the
the
the
Question
How can we get the browser properties using PHP?
s : 37
Answer : By using
$_SERVER['HTTP_USER_AGENT']
37
variable.
Question What is the maximum size of a file that can be uploaded
s : 38
using PHP
and how can we change this?
Answer : By default the maximum size is 2MB. and we can change the
38
following
setup at php.iniupload_max_filesize = 2M
Question
How can we increase the execution time of a PHP script?
s : 39
Answer : by changing the following setup at php.inimax_execution_time = 30
39
; Maximum execution time of each script, in seconds
Question How can we take a backup of a MySQL table and how can we
s : 40
restore
it. ?
Answer : To backup: BACKUP TABLE tbl_name[,tbl_name] TO
40
'/path/to/backup/directory'
RESTORE TABLE tbl_name[,tbl_name] FROM
'/path/to/backup/directory'mysqldump: Dumping Table Structure
and DataUtility to dump a database or a collection of database for
backup or
for transferring the data to another SQL server (not necessarily a
MySQL
server). The dump will contain SQL statements to create the table
and/or
populate the table.
-t, no-create-info
Don't write table creation information (the CREATE TABLE
statement).
Page 9
Question
How many ways can we get the value of current session id?
s : 42
Answer :
session_id() returns the session id for the current session.
42
Question How can we destroy the session, how can we unset the
s : 43
variable of
a session?
Answer : session_unregister Unregister a global variable from the current
43
session
session_unset Free all session variables
Question
How can we set and destroy the cookie n php?
s : 44
Answer : By using setcookie(name, value, expire, path, domain); function we
44
can set the cookie in php ;
Set the cookies in past for destroy. like
setcookie("user", "sonia", time()+3600); for set the cookie
setcookie("user", "", time()-3600); for destroy or delete the cookies;
Question How many ways we can pass the variable through the
s : 45
navigation
between the pages?
Answer :
45
GET/QueryString
POST
Question
What are the different functions in sorting an array?
s : 47
Answer : Sort(), arsort(),
47
asort(), ksort(),
natsort(), natcasesort(),
rsort(), usort(),
array_multisort(), and
uksort().
Question How can we know the count/number of elements of an
s : 48
array?
Answer : 2 ways
48
a) sizeof($urarray) This function is an alias of count()
b) count($urarray)
Question
what is session_set_save_handler in PHP?
s : 49
Answer : session_set_save_handler() sets the user-level session storage
49
functions which are used for storing and retrieving data associated
with a session. This is most useful when a storage method other
than those supplied by PHP sessions is preferred. i.e. Storing the
session data in a local database.
Question How can I know that a variable is a number or not using a
s : 50
JavaScript?
Answer : bool is_numeric ( mixed var)
50
Returns TRUE if var is a number or a numeric string, FALSE
otherwise.or use isNaN(mixed var)The isNaN() function is used to
check if a value is not a number.
Question List out some tools through which we can draw E-R diagrams
s : 51
for
mysql.
Answer : Case Studio
51
Smart Draw
Question How can I retrieve values from one database server and store
s : 52
them
in other database server using PHP?
Answer : we can always fetch from one database and rewrite to another. here
Page 11
Question
List out the predefined classes in PHP?
s : 53
Answer : Directory
53
stdClass
__PHP_Incomplete_Class
exception
php_user_filter
Question How can I make a script that can be bi-language (supports
s : 54
English, German)?
Answer : You can maintain two separate language file for each of the
54
language. all the labels are putted in both language files as variables
and assign those variables in the PHP source. on runtime choose the
required language option.
Question What are the difference between abstract class and
s : 55
interface?
Answer : Abstract class: abstract classes are the class where one or more
Page 12
Question
How can we send mail using JavaScript?
s : 56
Answer : JavaScript does not have any networking capabilities as it is
56
designed to work on client site. As a result we can not send mails
using
JavaScript. But we can call the client side mail protocol mailto
via JavaScript to prompt for an email to send. this requires the client
to approve it.
Question
How can we repair a MySQL table?
s : 57
Answer : The syntex for repairing a MySQL table is
57
REPAIR TABLENAME, [TABLENAME, ], [Quick],[Extended]
This command will repair the table specified if the quick is given the
MySQL will do a repair of only the index tree if the extended is given
it will create index row by row
Question What are the advantages of stored procedures, triggers,
s : 58
indexes?
Answer : A stored procedure is a set of SQL commands that can be compiled
58
and
stored in the server. Once this has been done, clients don't need to
keep re-issuing the entire query but can refer to the stored
procedure.
This provides better overall performance because the query has to
be
parsed only once, and less information needs to be sent between the
server and the client. You can also raise the conceptual level by
having
libraries of functions in the server. However, stored procedures of
course do increase the load on the database server system, as more
of
the work is done on the server side and less on the client
(application)
side.Triggers will also be implemented. A trigger is effectively a type
of
stored procedure, one that is invoked when a particular event
Page 13
64
Column
64
Index
64
Alias
255
they?
Page 17
Unique key?
Answer : Primary Key: A column in a table whose values uniquely identify the
72
rows in the table. A primary key value cannot be NULL.
Unique Key: Unique Keys are used to uniquely identify each row in
the
table. There can be one and only one row for each unique key value.
So
NULL can be a unique key.There can be only one primary key for a
table but there can be more
than one unique for a table.
Page 20
Page 21
Page 26