Showing posts with label PHP Interview Questions. Show all posts
Showing posts with label PHP Interview Questions. Show all posts

PHP Interview Questions Part I

I hope this would be helpful for the jobseekers.

This is "three part" article


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:
Get- sends requset in the form of qusery string and post hides the
data, and send directly to system.out


2. Who is the father of php and explain the php versions

Ans: Rasmus Lerdorf

3. How can we submit a form without a submit button

Ans:
1. image button 2. button. 3. java script form.submit() function

4. How many ways we can retrieve the date in result set of mysql using php

Ans:
4 ways, 1. mysql_fetch_row. 2. mysql_fetch_array. 3.
mysql_fetch_object 4. mysql_fetch_assoc


5. What is the difference between mysql_fetch_object and mysql_fetch_array

Ans:
mysql_fetch_object -- Fetch a result row as an object
mysql_fetch_array -- Fetch a result row as an associative array, a
numeric array, or both.


6. What is the difference between $message and $$message

Ans:
$message- is a varibale. $$message is a variable inside varibale


7. How can we extract string 'abc.com ' from a string 'http://info@abc.com' using regular expression of php

Ans:

$line="http://info@abc.com";
if (eregi ("http://(.*)@(.*)", $line, $add))
echo $add[2];


8. How can we create a database using mysql

Ans:
mysql_create_db in php. Create database name....

9. What is the differences between require and include, include_once

Ans:
include: warning require : fatal-error
include_once should be used in cases where the same file might be
included and evaluated more than once during a particular execution of a
script.


10. can we use include("myfile.php") two times in a php age "makeit.php"

Ans:
yes we can include twice.

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:
MYISAM, ISAM, MERGE, HEAP, INNODB, BERKLEYDB. The Default Type is
"MYISAM"

12. Functions in IMAP, POP3 AND LDAP

Ans:
Please check in the manual (some people say RTFM... no offence !)


15. Shopping cart online validation ie how can we configure the Nobel Pay

Ans:
It is done thru curlfunction card details will be sent to the page in Nobel pay site which is already given to us by them. Only we have to send the parameters which is required for calling that page.

PHP Interview Questions Part II

16. What is meant my nl2br()

Ans: like


19. What are the reasons for selecting lamp(Linux, apache, mysql, php) instead of combination of other software programmes, servers and operating system?

Ans: All are Open-Source and are related internally

20. How can we encrypt and decrypt a data present in a mysqltable using mysql

Ans: AES_ENCRYPT() AES_DECRYPT()

21. How can we encrypt the username and password using php

Ans: md5() sha1()

22. What are the features and advantages of OBJECT ORIENTED PROGRAMMING

Ans: Encapsulation and inheritence and ploymorphism

23. What are the differences between PROCEDURE ORIENTED LANGUAGES AND OBJECT ORIENTED LANGUAGES

Ans: procedural programming executes serially, and OOPS - memory is
alloted when the objects are created. no step by step execution.


24. what is the use of friend function (many say it as array)

Ans: we can use that function any where in the module not necessary to
create an instance of class.


26. What are the different types of errors in php

Ans: Fatal errors, Parse errors......

27. What is the functionality of the function strstr and stristr

Ans: strstr -- Find first occurrence of a string
stristr -- Case-insensitive strstr()


28. What are the differences between PHP 3 and PHP 4 and PHP 5

Ans: Every time they will include some new functionalities and some new
functions.....

29. How can we convert asp pages to php pages

Ans: There is a saperate tool for that

30. What is the functionality of the function htmlentities

Ans: htmlentities -- Convert all applicable characters to HTML entities

31. How can we get second of the current time using date function?

Ans: today = date("H:i:s");

33. What is meant by urlencode and urldocode

Ans: to encode urls, returns a string in which all non-alphanumeric
characters.

IF VS Switch (FBI MOST WANTED ?)

switch ( $action ) {
case ( 'FBI Most Wanted' ) :
$counter++;
break;

case ( 'Most Fuel Efficient Car' ) :
$counter++;
break;

case ( 'Most Expensive Car' ) :
$counter++;
break;
}

if ( $action == 'first' ) {
$counter++;
} elseif ( $action == 'Most Fuel Efficient Car' ) {
$counter++;
} elseif ( $action == 'Most Expensive Car' ) {
$counter++;
}


Obviously Switch is a lot cleaner to read !