PHP Question and answers
Do you need to initialize the variable before its usage? Why?
Ans: Actually, Its not mandatory in php. But its recommended to
initialize variable before its usage. In most of the servers the the
error reporting for display notices are disabled. In the case of
servers which enabled error reporting on for notices, its highly
recommended to initialize variable before its usage.
How do you use a function's parameters inside the function?
Ans: Information are passed to the functions as parameters
separated by commas. We can handle these parameters in several ways.
We can pass variables into the function
We can pass arrays to the function
We can set default argument values in the function parameters.
There are two non-empty arrays $a and $b. What is the result of their sum (+) ?
Ans: it will return the value of $a (the first array);
Comment the following code: $q = 'SELECT * FROM mytable WHERE id = ' . $_POST['id'] ? Is there any possibility to make it better?
Ans: $q = 'SELECT * FROM mytable WHERE id = ' . htmlentities ( mysql_real_escape_string ( $_POST['id'] ) );
How do you swap the values of string variables $a and $b, without using a third variable?
Ans : $a = "content";
$b = "not a content";
list($a,$b) = array($b,$a);
echo "new a is - ". $a;
echo "
new b is - ".$b;
What way will you choose to sort the array of strings?
Ans: Will use asort() function.
What methods can you use to start a PHP block? Which is best,and why?
Ans: we can use tags
tags
<% %> tags
The best on is tag. Because its the default code block
of php. It works on all servers , no need to edit the php.ini settings
in the server. The other blocks are referred as short tags. Its server
specific, needs to edit in the php.ini settings to activate them.
Will be the value of $a after the execution of the following line of code: $a = include 'somefile.php'; ?
Ans: It will execute the script in it
Describe the advantages and disadvantages of the various ways of configuring a Web server to process PHP scripts.
Ans: Please post your the answer as comments below
What are the sessions. How is sessions data stored at the server?
Ans: Session is defined as the instance between when a user starts a
requests to a particular webserver and closing the requests to that
server.
These informations can stored server based on the session ids. We can
store these informations on the server in its local memory, files, or
in the databases.
[Friday, August 29, 2008
|
1 comments
]
Popular Posts
- MySQL stored procedure&triggers
- php questions
- Php Questions
- How we canmove into last changed position on info window close event On google map
- Pattern Matching in mysql
- MySQL INDEX
- MYSQL joins
- Jquery based dynamic adding and removal of html elements.
- securing a form with captcha
- Comparing a date with current date
1 comments
2/5 :)
Post a Comment
Please put your comments here. your questions, your suggestions, also what went wrong with me.