-->
GET :
- GET method have not security because of data view in
addressbar. For ex: we can not use this method for checking
login
- We can bookmark link with this method
- Server can log all action
- because of server log, we can pass 255 char. as query
string
POST:
- POST method have security of data.
- We can not bookmark page link
- We can pass unlimited data by this method as query string
2. How can we submit a form without a submit button?
--> you can submit a form with javascript like this:
document.forms[0].submit();
3. In how many ways we can retrieve the data in the result set of mysql using PHP?
--> 4 ways
1. mysql_fetch_rows
2. mysql_fetch_object
3. mysql_fetch_assoc
4. mysql_fetch_array
4. What is the difference between mysql_fetch_object and mysql_fetch_array?
-->
mysql_fetch_object : will return the results from database
as objects. fields will be accessible like in objects
i.e $result->name,$result->cust_name
mysql_fetch_array : will return the results from database as
array. fields will be accessible like in objects
i.e $result[name],$result[cust_name]
5. What is the difference between $message and $$message?
-->
$Message = "YOU";
$you= "Me";
echo $message //Output:- you
echo $$message //output :-Me
It means
$message is a variable and
$$Message is variable of variable
A variable of variable allows us to change the name of
variable dinamically
6. What are the differences between require and include, include_once?
-->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. To read more look here:
http://en.wikipedia.org/wiki/Captcha
8. If you have to work with dates in the following format: "Tuesday,
February 14, 2006 @ 10:39 am", how can you convert them to another
format, that is easier to use?
-->
The strtotime function can convert a string to a timestamp. A timestamp
can be converted to date format. So it is best to store the dates as
timestamp in the database, and just output them in the format you like.
So let's say we have
$date = "Tuesday, February 14, 2006 @ 10:39 am";
In
order to convert that to a timestamp, we need to get rid of the "@"
sign, and we can use the remaining string as a parameter for the
strtotime function.
So we have
$date = str_replace("@ ","",$date);
$date = strtotime($date);
now $date is a timestamp
and we can say:
echo date("d M Y",$date);
9. How we know 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'] . "
\n";
$browser = get_browser();
foreach ($browser as $name => $value) {
echo "$name $value
\n";
}
10. How i will check that user is, logged in or not. i want to make it a function and i want to use in each page and after login i want to go in current page(same page. where i was working)?
-->For this we can use the session objec($_SESSION)t. When the user login with his/ her user name and password, usually we check those to ensure for correctness. If that user name and password are valid one then we can store that user name in a session and then we can very that session variable has been set or not in a single files and we can include that file in all pages.
11. How i can get ip address?
-->We can use SERVER var $_SERVER['SERVER_ADDR'] and getenv("REMOTE_ADDR") functions to get the IP address.
12. What is differenc between mysql_connect and mysql_pconnec?
-->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 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.
13. 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.
14. 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
No comments:
Post a Comment