PHP-Mysql Interview Questions
Q:1
How can we submit a form without a submit button?
A:1
The main idea behind this is to use Java script submit() function in
order to submit the form without explicitly clicking any submit button.
You can attach the document.formname.submit() method to onclick,
onchange events of different inputs and perform the form submission.
you
can even built a timer function where you can automatically submit the
form after xx seconds once the loading is done (can be seen in online
test sites).
Q:2
In how many ways we can retrieve the data in the result set of MySQL using PHP?
A:2
You can do it by 4 Ways
1. mysql_fetch_row.
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc
Q:3
What is the difference between mysql_fetch_object and mysql_fetch_array?
A:3
mysql_fetch_object() is similar to
mysql_fetch_array(),
with one difference - an object is returned, instead of an array.
Indirectly, that means that you can only access the data by the field
names, and not by their offsets (numbers are illegal property names).
Q:4
What is the difference between $message and $$message?
A:4
It is a classic example of PHP’s variable variables. take the following
example.$message = “Mizan”;$$message = “is a moderator of
PHPXperts.”;$message is a simple PHP variable that we are used to. But
the $$message is not a very familiar face. It creates a variable name
$mizan
with the value “is a moderator of PHPXperts.” assigned. break it like
this${$message} => $mizanSometimes it is convenient to be able to
have variable variable names. That is, a variable name which can be set
and used dynamically.
Q:5
How can we extract string ‘abc.com ‘ from a string ‘http://info@abc.com’
using regular expression of PHP?
A:5
preg_match(”/^http:\/\/.+@(.+)$/”,’http://info@abc.com’,$found);
echo $found[1];
Q:6
How can we create a database using PHP and MySQL?
A:6
We can create MySQL database with the use of
mysql_create_db(“Database Name”)
Q:7
What are the differences between require and include, include_once and require_once?
A:7
The
include() statement includes and evaluates the specified file.The documentation below also applies to
require(). The two constructs are identical in every way except how they handlefailure.
include() produces a Warning while
require() results in a Fatal Error. In other words, use
require() if you want a missingfile to halt processing of the page.
include() does not behave this way, the script will continue regardless.
The
include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the
include()
statement, with the only differencebeing that if the code from a file
has already been included, it will not be included again. As the name
suggests, it will be included just once.
include_once() should be
used in cases where the same file might be included and evaluated more
than once during a particularexecution of a script, and you want to be
sure that it is included exactly once to avoid problems with function
redefinitions, variable value reassignments, etc.
require_once() should be used in cases where the same file might be
included and evaluated more than once during a particular execution of
a script, and you want to be sure that it is included exactly once to
avoid problems with function redefinitions, variable value
reassignments, etc.
Q:8
Can we use include (”abc.PHP”) two times in a PHP page “makeit.PHP”?
A:8
Yes we can use include() more than one time in any page though it is not a very good practice.
Q:9
What are the different tables present in MySQL, which type of table
is generated when we are creating a table in the following syntax:
create table employee (eno int(2),ename varchar(10)) ?
A:9
Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. INNO DB
5. ISAM
MyISAM is the default storage engine as of MySQL 3.23 and as a result
if we do not specify the table name explicitly it will be assigned to
the default engine.
Q:10
How can we encrypt the username and password using PHP?
A:10
The functions in this section perform encryption and decryption, and compression and uncompression:
encryption decryption
AES_ENCRYT() AES_DECRYPT()
ENCODE() DECODE()
DES_ENCRYPT() DES_DECRYPT()
ENCRYPT() Not available
MD5() Not available
OLD_PASSWORD() Not available
PASSWORD() Not available
SHA() or SHA1() Not available
Not available UNCOMPRESSED_LENGTH()
Q:11
Describe functions STRSTR() and STRISTR.
AnswerBoth the functions are used to find the first occurrence of a string. Parameters includes: input String, string whose occurrence needs to be found, TRUE or FALSE (If TRUE, the functions return the string before the first occurrence.
STRISTR is similar to STRSTR. However, it is case-insensitive
E.g. strstr ($input_string, string)
Q:12 What is Full form of PHP ? Who is the father or inventor of PHP ?
answer: Rasmus Lerdorf is known as the father of PHP that started development of PHP in 1994
for their own Personal Home Page (PHP) and they released PHP/FI (Forms Interpreter) version 1.0 publicly on 8 June 1995 But in 1997 two Israeli developers named Zeev Suraski and Andi Gutmans rewrote the parser that formed the base of PHP 3 and then changed the language's name to the PHP: Hypertext Preprocessor.
Q:13 What are the differences between Get and post methods.
Answer: There are some defference between GET and POST method
1. GET Method have some limit like only 2Kb data able to send for request
But in POST method unlimited data can we send
2. when we use GET method requested data show in url but
Not in POST method so POST method is good for send sensetive request
Q:12 |
What is meant by nl2br()? |
Ans: |
Inserts HTML line breaks (<BR />) before all newlines in a string. |
|
|
|
|
Q:13 |
What is htaccess? Why do we use this and Where? |
Answers |
.htaccess files are configuration files of Apache Server which provide
a way to make configuration changes on a per-directory basis. A file,
containing one or more configuration directives, is placed in a particular
document directory, and the directives apply to that directory, and all
subdirectories thereof. |
Q: 14 |
What are the features and advantages of object-oriented
programming? |
Answer |
One of the main advantages of OO programming is its ease of
modification; objects can easily be modified and added to a system there
by reducing maintenance costs. OO programming is also considered to be
better at modeling the real world than is procedural programming. It
allows for more complicated and flexible interactions. OO systems are
also easier for non-technical personnel to understand and easier for
them to participate in the maintenance and enhancement of a system
because it appeals to natural human cognition patterns.
For some systems, an OO approach can speed development time since many
objects are standard across systems and can be reused. Components that
manage dates, shipping, shopping carts, etc. can be purchased and easily
modified for a specific system |
Q: 15 |
What is meant by MIME?
|
Answer | Multipurpose Internet Mail Extensions.
WWW ability to recognise and handle files of different types is largely
dependent on the use of the MIME (Multipurpose Internet Mail Extensions)
standard. The standard provides for a system of registration of file
types with information about the applications needed to process them.
This information is incorporated into Web server and browser software,
and enables the automatic recognition and display of registered file
types. |
Q: 16 |
What is meant by PEAR in php?
|
Answer | PEAR
is short for "PHP Extension and Application Repository" and is
pronounced just like the fruit. The purpose of PEAR is to provide:
A structured library of open-sourced code for PHP users
A system for code distribution and package maintenance
A standard style for code written in PHP
The PHP Foundation Classes (PFC),
The PHP Extension Community Library (PECL),
A web site, mailing lists and download mirrors to support the PHP/PEAR community
PEAR is a community-driven project with the PEAR Group as the
governing body. The project has been founded by Stig S. Bakken in 1999
and quite a lot of people have joined the project since then.
|