Sie sind auf Seite 1von 3

PHP Interview Questions & Answers

PHP Interview Questions & Answers


1. What is the difference between echo and print?
echo: Is a command only , Faster than print
print: Is a function , It will return true(1) or false(0) or some values.
2. How can we submit a form without a submit button?
A form in Javascript can be submitted using document.formname.submit();
Other functions like PHP's header ("location :$url"); is transfering control from
one page to another. It is not submitting form.
In Javascript window.location(url) is also transfering control from one page to
another without submission form.
3. What type of inheritance that php supports?
PHP supports only single inheritance. But multiple inheritance can be
implemented in php through use of interface.
4. POST and GET Methods : Which will execute faster POST or GET? Explain?
Once most important difference is when you are sending the form with GET
method. It displays name/value pair used in the form at the address bar of
the browser preceded by url.
Whereas if you send the form with POST method then user can not see that
information and Secondly When you want to send short or small data & Less
Sensitive Data then you can use GET Method. But for long data & Sensitive
Data sending say more then 100 character you can use POST method
5. Why do we put @ symbol before any variable?
@ symbol when placed before any variable will hide notices and warnings
which are generated when trying to access an undefined variable.
6. How do you know (status) whether the recipent of your mail had opened the
mail i.e read the mail? Or Is there any method of checking whether the email
has opened by the end user ?
In PHP we can use "Disposition-Notification-To:" in header function.

7.

What are the differences between GET and POST methods in form
submitting, give the case where we can use get and we can use post
methods?
Answer: On the server side, the main difference between GET and POST is
where the submitted is stored. The $_GET array stores data submitted by the
GET method. The $_POST array stores data submitted by the POST method.
On the browser side, the difference is that data submitted by the GET method
will be displayed in the browser's address field. Data submitted by the POST
method will not be displayed anywhere on the browser. GET method is
mostly used for submitting a small amount and less sensitive data. POST
method is mostly used for submitting a large amount or sensitive data.

8. What are the different tables (Engine) present in MySQL, which one is
default?
Following tables (Storage Engine) we can create

MyISAM (The default storage engine IN MYSQL Each MyISAM table is


stored on disk in three files. The files have names that begin with the
table name and have an extension to indicate the file type. An .frm file
stores the table format. The data file has an .MYD (MYData) extension.
The index file has an .MYI (MYIndex) extension. )

InnoDB (InnoDB is a transaction-safe (ACID compliant) storage engine


for MySQL that has commit, rollback, and crash-recovery capabilities to
protect user data.)

Merge

Heap (MEMORY) (The MEMORY storage engine creates tables with


contents that are stored in memory. Formerly, these were known as
HEAP tables. MEMORY is the preferred term, although HEAP remains
supported for backward compatibility. )

BDB (BerkeleyDB)(Sleepycat Software has provided MySQL with the


Berkeley DB transactional storage engine. This storage engine typically
is called BDB for short. BDB tables may have a greater chance of
surviving crashes and are also capable of COMMIT and ROLLBACK
operations on transactions)

EXAMPLE

FEDERATED (It is a storage engine that accesses data in tables of


remote databases rather than in local tables. )

ARCHIVE (The ARCHIVE storage engine is used for storing large


amounts of data without indexes in a very small footprint. )

CSV (The CSV storage engine stores data in text files using commaseparated values format.)

BLACKHOLE (The BLACKHOLE storage engine acts as a "black hole"


that accepts data but throws it away and does not store it. Retrievals
always return an empty result)

9. What is htaccess? Why do we use this and Where?


.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.
10.How to prevent form hijacking in PHP?
a. Make register_globals to off to prevent Form Injection with malicious
data.
b. Make Error_reporting to E_ALL so that all variables will be intialized
before using them.
c. Make practice of using htmlentities(), strip_tags(), utf8_decode() and
addslashes() for filtering malicious data in php
d. SQL injection attacks by using mysql_escape_string().
e. User Input Sanitization-Never trust web user submitted data. Follow
good clieint side data validation practices with regular expressions
before submitting data to the serve.
f.

Form Submision Key Validation: A singleton method can be used to


generate a Session form key & validating form being submitted for the
same value against hidden form key params.

Das könnte Ihnen auch gefallen