Friday, March 18, 2011

PHP Interview Question Part 2


1. What is the difference between echo and print statement?
There is a slight difference between print and echo which would depend on how you
want to use the outcome. Using the print method can return a true/false value. This may
be helpful during a script execution of somesort. Echo does not return a value, but has
been considered as a faster executed command. All this can get into a rather
complicated discussion, so for now, you can just use whichever one you prefer.

2.How to make a download page in own site, which i can know that how many file has
been loaded by particular user or particular ipaddress?

We can use hyperlink having URL where file are kept. and we only allow regisetered
user to download. from session of user we can get the user detail

3. What is the difference between mysql_connect and mysql_pconnect?
 mysql_pconnect establishes a persistent connection. If you don't need one (such as a
website that is mostly HTML files or PHP files that don't call the db) then you don't
need to use it. mysql_connect establishes a connection for the duration of the script
that access the db. Once the script has finished executing it closes the connection. The
Templateshut.com
only time you need to close the connection manually is if you jump out of the script for
any reason.
If you do use mysql_pconnect. You only need to call it once for the session. That's the
beauty of it. It will hold open a connection to the db that you can use over and over
again simply by calling the resource ID whenever you need to interact with the db.

4. How can I get IP Address?
We can use SERVER var $_SERVER['SERVER_ADDR'] and getenv("REMOTE_ADDR")
functions to get the IP address.

5. How we know the browser properties?
get_browser() attempts to determine the capabilities of the user's browser. This is done
by looking up the browser's information in the browscap.ini file.
echo $_SERVER['HTTP_USER_AGENT'] . "

6. What is the difference between require_once(), require(), include().
Difference between require() and require_once(): require() includes and evaluates a
specific file, while require_once() does that only if it has not been included before (on
the same page). So, require_once() is recommended to use when you want to include a
file where you have a lot of functions for example. This way you make sure you don't
include the file more times and you will not get the "function re-declared" error.
Difference between require() and include() is that require() produces a FATAL ERROR
if the file you want to include is not found, while include() only produces a WARNING.
There is also include_once() which is the same as include(), but the difference between
them is the same as the difference between require() and require_once().

7. What is CAPTCHA?
CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and
Humans Apart. To prevent spammers from using bots to automatically fill out forms,
CAPTCHA programmers will generate an image containing distorted images of a string
of numbers and letters. Computers cannot determine what the numbers and letters are
from the image but humans have great pattern recognition abilities and will be able to
fairly accurately determine the string of numbers and letters. By entering the numbers
and letters from the image in the validation field, the application can be fairly assured
that there is a human client using it.

No comments:

Post a Comment