Sunday, May 1, 2011

Latest PHP Interview Question Answers | Basic & Most asked Question of PHP

SOCIALIZE IT →


Q 1)Which function in PHP gives us absolute path of a file on the server?
< ?php $p = getcwd(); echo $p; ?> Ans: getcwd() Here I have stored my files under httdocs (using php5,i haven’t checked under php4) so I get the output as C:\apache2triad\htdocs you may get your path information while runnings the above code.

Q 2)what is the php solution to dynamic caching ?
www.w3answers.com PHP offers an extremely simple solution to dynamic caching in the form of output buffering.

Q 3)What is the difference between strstr() and stristr()?
strstr — Find first occurrence of a string strstr() example < ?php$email = 'user@example.com';$domain = strstr($email, '@');echo $domain; // prints @example.com?> stristr — Case-insensitive strstr() stristr() example < ?php$email = 'USER@EXAMPLE.com';echo stristr($email, 'e');// outputs ER@EXAMPLE. ....!
Is it possible to set a time expire page in PHP.?
Yes it is Using header("Expires: Mon, 26 Jul 2007 05:00:00 GMT"); .

Q 4)What is MIME?
MIME is Multipurpose Internet Mail Extensions is an internet standard for the format of e-mail. Howewer browsers also uses MIME standart to transmit files. MIME has a header wich is added to a begining of the data. When browser sees such header it shows the data as it would be a file (for example image) some mimes:audio/x-ms-wmpimage/pngaplication/x-shockwave-flash .
5)What is the maximum length of a table name, a database name, or a field name in MySQL?
Ans: Database name: 64 characters Table name: 64 characters Column name: 64 characters ….!
php supports following database
a) Solid & oracle b) mysql c) None of the above d) All of the above All of the above ….!
what are the ‘function problems’ you have met in php?
1)Call to undefined function we_w3answers() ***************************************** PHP is trying to call the function we_w3answers(), which has not been because you misspelled the name of a function (built-in or user-defined) simply omitted the function definition. If you use include/require functions, make sure that you are loading the appropriate files. 2)Call to undefined function array() *********************************** This problem has a cause that i….!

Q 6)What is meant by Exceptional Handling?
Exceptions PHP 5 has an exception model similar to that of other programming languages. An exception can be thrown, try and caught within PHP. A Try block must include at least one catch block. Multiple catch blocks can be used to catch different classtypes; execution will continue after that last catch block defined in sequence. Exceptions can be thrown within catch blocks. When an exception is thrown, code following the statement will not be executed and PHP will attempt to find the first matching catch block. ….!
Q 7)what is the output here?
< ?php var_dump(0 == "a"); ?>
a) false
b) true
c) error
d) declaration error ANS : true ….!

Q 8)What will be the following script output?
< ?php$a = 1;$a = $a— + 1;echo $a;?>
A. 2
B. 1
C. 3
D. 0
E. Null Answer : B is correct. ….!

Q 9)What are the different functions in sorting an array?
Ans: asort() arsort() ksort() krsort() uksort() sort() natsort() rsort() ….!

Q 10)What is the difference between the functions unlink() and unset()?
unlink is a function for file system handling. It will simply delete the file in context unset will set UNSET the variable ….!

Q 11)What will be the following script output?
< ?php$x = 3 - 5 % 3;echo $x;?>
A. 2
B. 1
C. Null
D. True
E. 3 Answer A is correct. Because of operator precedence, the modulus operation isperformed first, yielding a result of 2 (the remainder of the division of 5 by 2).Then, the result of this operation is subtracted from the integer 3. ….!

Q 12)< ?php
$x = 3 - 5 % 3;
echo $x;
?>
A. 2
B. 1
C. Null
D. True
E. 3 Answer A is correct.
Because of operator precedence, the modulus operation is
performed first, yielding a result of 2 (the remainder of the division of 5 by 2).
Then, the result of this operation is subtracted from the integer 3.
….!

0 comments :

Post a Comment