Hey, I am back with some more questions on PHP. Enjoy!!
Q:- What is the difference between “GET” and “POST” methods?
Ans. Get and Post are methods used to send data to the server with the submission of the form. The default method is GET.
* The browser appends the data onto the url when GET method is used, while the data is sent as standard input when POST method is used.
* When the processing of the form has no side effects, means just for getting(retrieving) data, the GET method should be used and POST method should be used when the form processing has side effects(for example, modification of a database or subscription to a service).
Example: Suppose Sachin is filling up a form with the following information:
Name: Sachin Tendulkar
Age:35
Sex:Male
Choice:Cricket
If the form uses GET method then the location box will show the string after submitting the form like this:
http://cricketworld.com/cgi-bin/query?Name=Sachin+Tendulkar &Age=35&Sex=Male&Choice=Cricket
and if POST is used, then the location box will show:
http://cricketworld.com/cgi-bin/query
Q:- What is the difference between echo and print?
Ans. Both are the constructs to print the string on the screen. echo just outputs the contents to the screen following the construct while print returns TRUE on successful output and FALSE if it was unable to print out the string. echo can take multiple parameters while print cannot. Also echo is faster than print in execution.
Q:- What is the difference include() and require()?
Ans. Both the functions are used to include and evaluate the specific file, but the only difference is require() produces FATAL ERROR and stops the execution if the specified file is not found while include() produces a warning message only and proceeds the execution.
Q:- What is meant by nl2br()?
Ans. This function inserts HTML line breaks before all newlines in a string
example: <?php
echo nl2br(“I am not getting\n what you are saying”);
?>
Output: I am not getting<br />
what you are saying
Q:- What is the differen between strstr() and stristr() functions?
Ans. strstr() function is used to return the sub string from first occurrence of string point from the string base.If string point is not found, returns FALSE. syntax: strstr(string base,string point)
examle: <?php
$email = ‘mayank@gmail.com’;
$domain = strstr($email, ‘@’);
echo $domain;
?>
output: @gmail.com
stristr() does the same thing in Case-insensitive manner.
Who will come with smart comments? Let’s see.
Nice Blog. These are very good questions and answers for interview.
Thanks
Thanks
gr8 work Asit
N’Joy Life till not Wife
rAVI
I didn’t get properly what’s the use of nl2br() ?
Will you explain it more?
Sure, I like your approach. I will come with some more examles on nl2br().
Thanks!!
These are very good questions and answers for interview.please give me more interview questions and their answers plz.
Thanks for your response. I will try to get back with some more stuff.
Hi,
Its great to collect such quetions and answering them.
Can u give me the difference of sessions and cookies in PHP
Thanking you
regards
amul
hi
Thanks for you
Hi Check my online profile from here-
http://mayanksrivastava.cv.googlepages.com
Thanks? Shall i get more inte ques from u Asit..
i want code for resume uploading with out creating database,so plzz forward code to my email
thanks®ards
dilip
Great blog, reading it through RSS feed as well