here are the answer for most of the questions post..
1. 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?
Ans :-
In the get method the data made available to the action page ( where data is received ) by the URL so data can be seen in the address bar. Not advisable if you are sending login info like password etc. In the post method the data will be available as data blocks and not as query string in case of get method.
2. Who is the father of php and explain the changes in php versions?
Ans :-
Rasmus Lerdorf for version changes goto http://php.net/
3. How can we submit from without a submit button?
Ans:-
Trigger the JavaScript code on any event ( like onselect of drop down list box, onfocus, etc ) document.myform.submit();This will submit the form.
4. How many ways we can retrieve the date in result set of mysql using php?
Ans:-
As individual objects so single record or as a set or arrays.
5. What is the difference between mysql_fetch_object and mysql_fetch_array?
Ans:-
MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array
6. What is the difference between $message and $$message?
Ans:-
Both are variables only
$message is a variable and if used with print statement, the content of the $message variable will be displayed. Where as with $$message variable, the content of the $message will also be treated as variable and the content of that variable will be displayed. For ex: If $message contains "var", then it displays the content of $var on the screen.
7. How can we extract string 'abc.com ' from a string 'http://info@abc.com' using regular _expression of php?
Ans:-
preg_match("/^(http://info@)?([^/]+)/i","http://info@abc.com", $data);
echo $data[2];
Use the function split split(“@”,”http://info@abc.com”) which returns an array any second element of the returned array will hold the value as abc.com.
8. How can we create a database using php and mysql?
Ans:-
mysql_create_db()
9. What are the differences between require and include, include_once?
Ans:-
File will not be included more than once.
If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
10. Can we use include ("abc.php") two times in a php page "makeit.php"?
Ans:-
Yes we can include..
11. 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)) ?
Ans:-
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.
Table Types are
· ISAM(Index Sequential Access Method)
· MyISAM
o Static
o Dynamic
o Compress
· Merge
· Heap (Fastest tables because it stores in to the RAM)
· BDB
· InnoDB (Transaction safe table)
When you fire the above create query MySQL will create the Dynamic table.
http://dev.mysql.com...ge-engines.html
MyISAM Table Type is created, if u not specified any table type then default will be applied and MyISAM is default
13. How can I execute a PHP script using command line?
Ans:-
Through php parse you can execute PHP script using command line. By default location of php parser is /var/www/html so set the path of this directory and just use as following
#php sample.php
16. What is meant by nl2br()?
Ans:-
nl2br() inserts html in string
echo nl2br(”god bless n you”);
output--
god bless
you
Returns string with ‘’ inserted before all newlines
20. How can we encrypt and decrypt a data present in a mysql table using mysql?
Ans:-
AES_ENCRYPT() and AES_DECRYPT()
21. How can we encrypt the username and password using PHP?
Ans:-
You can encrypt a password with the following
Mysql>SET PASSWORD=PASSWORD("Password");
26. What are the different types of errors in PHP?
Ans:-
Three are three types of errors 1) Fatal errors 2) Parser errors 3) Startup errors.
27. What is the functionality of the function strstr and stristr?
Ans:-
string strstr ( string str1, string str2) this function search the string str1 for the first occurrence of the string str2 and returns the part of the string str1 from the first occurrence of the string str2. This function is case-sensitive and for case-insensitive search use stristr() function.
28. What are the differences between PHP 3 and PHP 4 and PHP 5?
Ans:-
for this ans goto http://php.net and check the version changes
29. How can we convert asp pages to PHP pages?
Ans:-
You can download asp2php front end application from the site http://asp2php.naken.cc.
33. What is meant by urlencode and urldocode?
Ans:-
string urlencode(str)
where str contains a string like this "hello world" and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello%world
string urldocode(str)
this will simple decode the GET variable’s value
Like it echo (urldecode($_GET_VARS[var])) will output "Hello world"
34. What is the difference between the functions unlink and unset?
Ans:-
unlink is a function for file system handling. It will simply delete the file in context
unset will set UNSET the variable. e.g
35. How can we register the variables into a session?
Ans:-
Yes we can
session_register($ur_session_var);
42. How many ways can we get the value of current session id?
ans:-
session_id() returns the session id for the current session.
43. How can we destroy the session, how can we unset the variable of a session?
Ans:-
session_unregister -- Unregister a global variable from the current session
session_unset -- Free all session variables
44. How can we destroy the cookie?
Ans:-
Set the cookie in past
45. How many ways we can pass the variable through the navigation between the pages?
Ans:-
GET or QueryString and POST
46. What is the difference between ereg_replace() and eregi_replace()?
Ans:-
eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.eregi_replace() function is identical to ereg_replace() except that this ignores case distinction when matching alphabetic characters.
47. What are the different functions in sorting an array?
Ans:-
Sorting functions in PHP,
asort-http://www.php.net/manual/en/function.asort.php
arsort-http://www.php.net/manual/en/function.arsort.php
ksort-http://www.php.net/manual/en/function.ksort.php
krsort-http://www.php.net/manual/en/function.krsort.php
uksort-http://www.php.net/manual/en/function.uksort.php
sort-http://www.php.net/manual/en/function.sort.php
natsort-http://www.php.net/manual/en/function.natsort.php
rsort-http://www.php.net/manual/en/function.rsort.php
48. How can we know the count/number of elements of an array?
Ans:-
2 ways
a) sizeof($urarray) This function is an alias of count()
interestingly if u just pass a simple var instead of a an array it will return 1.
53. List out the predefined classes in PHP?
Ans:-
1. Standard Defined Classes
These classes are defined in the standard set of functions included in the PHP build.
a. Directory
The class from which dir() is instantiated.
b.stdClass
2.Ming Defined Classes
These classes are defined in the Ming extension, and will only be available when that
extension has either been compiled into PHP or dynamically loaded at runtime.
a.swfshape
b. swffill
c. swfgradient
d. swfbitmap
e. swftext
f. swftextfield
g. swffont
h. swfdisplayitem
i. swfmovie
j. swfbutton
k. swfaction
l. swfmorph
m. swfsprite
3. Oracle 8 Defined Classes
These classes are defined in the Oracle 8 extension, and will only be available when
that extension has either been compiled into PHP or dynamically loaded at runtime.
a. OCI-Lob
b. OCI-Collection
4. qtdom Defined Classes
These classes are defined in the qtdom extension, and will only be available when that
extension has either been compiled into PHP or dynamically loaded at runtime.
a. QDomDocument
b. QDomNode
56. How can we send mail using JavaScript?
Ans:-
No You can't send mail using Javascript but u can execute a client side email client to send the email using mailto: code.
Using clientside email client
function myfunction(form)
{
tdata=document.myform.tbox1.value;
location="mailto:mailid@domain.com?subject="+tdata+"/MYFORM";
return true;
}
This question is wrong. You aren’t really ’sending mail’ when doing a ‘mailto’ and so it’s a misleading question… A smart candidate would just say “It’s not possible” and you may write him off.
57. What is meant by PEAR in php?
Ans:-
PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install "packages"
58. What is the purpose of the following files having extensions 1) frm 2) MYD 3) MYI. What these files contains?
Ans:-
In MySql, the default table type is MyISAM.
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.
The `.frm' file stores the table definition.
The data file has a `.MYD' (MYData) extension.
The index file has a `.MYI' (MYIndex) extension,
well i tryed myself to answer most of the questions..and may be u may get more robost answer for these questions..
now u can have little idea abt the php frm these answers...
and if u hv better answer dan i posted pls email me at skone.sk@gmail.com
regards
-skone ( shekhar koli)












