Hi all,

Well i understand that PHP today is everyone’s favorite technology today. And i must confess that this web scripting language not only gave me financial gains in my life but also is responsible for my social well being. People do regard me as a PHP guru and not just a lost geek any more. I started my career in php assuming that this language is very brief and i will be over with it with in a year or so, however it got the other way and i am still working on it. Now to cut this “My o MY” story short, let me share my experience with you guys.

General Interview preparation :

Be confident, Be Smart !! that is all you need to be when you are appearing for an interview. You do not know anything just do not be hesitated instead be true.

Some Do’s in the interview

  1. Wear a nice natural smile
  2. Wear calm bright color, blue is cool, my favorite. But i personally do not care much and i wear anything casual also, depends upon the company to company. But if you are a fresher please do not try anything ODD.
  3. Read your resume well
  4. Get your basics clear

DO NOT TRY TO GIVE HYPOTHETICAL ANSWERS, cause that way you are proving that the interviewer is dumb :p

Basica Technical preparation :

Preparing or hardening your basics for php is the key to clear interview, but being a fresher i or even the interviwer does not expect 100% correct or convincing answers. But if you are able to hit somewhat nearby chords of the question (please make sure you talk relevant) then it is going to get you through. Few questions here :

What is php ?

PHP: Hypertext PreProcessor , is a scripting language originally designed for producing dynamic web pages. It has evolved to include a command line interface capability and can be used in standalone graphical applications. Source Wikipedia

Difference between echo & printf ?

Source : faqts.com

1. Speed. There is a difference between the two, but speed-wise it should be irrelevant which one you use. echo is marginally faster since it doesn’t set a return value if you really want to get down to the nitty gritty.
2. Expression. print() behaves like a function in that you can do:

$ret = print “Hello World”; And $ret will be 1.

That means that print can be used as part of a more complex expression where echo cannot. An example from the PHP Manual:

$b ? print “true” : print “false”;

print is also part of the precedence table which it needs to be if it is to be used within a complex expression. It is just about at the bottom of the precedence list though. Only “,” AND, OR and XOR are lower.

3. Parameter(s). The grammar is: echo expression [, expression[,expression] … ] But echo ( expression, expression ) is not valid.

This would be valid: echo (“howdy”),(“partner”); the same as: echo “howdy”,”partner”; (Putting the brackets in that simple example serves no purpose since there is no operator precedence issue with a single term like that.)

So, echo without parentheses can take multiple parameters, which get concatenated:
echo “and a “, 1, 2, 3; // comma-separated without parentheses

echo (“and a 123”); // just one parameter with parentheses

print() can only take one parameter:
print (“and a 123”);
print “and a 123”;

What does php work ?

I will be very brief in this.

The logic lies on the server and is written in the form of classes and methods. The php code is written in .php file which resides at server which may or may not contain HTML,javscript or any other supported language. When the request is sent from client using a browser it reaches server and searches for the particular php file (which is requested by URL or form). If the file is found request is processed or handles as per the logic, but if the file is not found then a “404 Page not found” response is sent back to the client or browser. The response sent may be in the form of plan text,image or any other media type.Let me enlist these steps :

1) Request is sent to browser and a connection is made

2) Server processes the request as per client’s request

3) Request processed and the response is sent back to the browser

4) Connection is closed.

What is the difference between client side language and server side language, give examples ?

Client Side Language (like javascript) is totally dependent on browser. If your browser (which is at client side) does not support javacript then there is no client side language. Client side language cannot access database from the server. But it is used to do fancy stuff like drag & drop, validation etc. On the other hand, server side language is compiled/parsed at the server and the response is sent back to client each time the request is received. Example is php,jsp etc

Difference between Get and Post ?

I will be brief again.

If the form method is Get then the content of the form are sent to the server using URL. The are concatenated in the url and then processed at the server (using $_GET in case of php). In case of post data is sent to the server within the request and is not displayed in the URL, hence safer to send password or other confidential information. Get has certain size limitation where as post does not have such limitation.

Difference between $_GET and $_POST ?

$_GET, is used to access the name-value pair which is sent by the client to the server using GET method. $_POST can access the name-value pair which is sent by the client to the server using POST method.

What is $_REQUEST method for ?

$_REQUEST has combined value of $_GET and $_POST, hence can be used to access either of the values. But other than this it contains values of the cookie also. So $_REQUEST contains name-value pair of $_GET,$_POST,$_COOKIE arrays.

How do you set/unset a cookie ?

Cookie can be set using the setcookie() method in php.An example could be this :

//sets a cookie<br />
setcookie("TestCookie", $value, time()+3600);  /* expire in 1 hour */<br />
//unsets a cookie<br />
setcookie("TestCookie", $value, time()-3600);  /* cookie set in past will of course expire */

Lots of other questions, and i cannot write their answers here right now. Will of course do them in future. For now please search in google or if you know them please leave answers in comments so that other users can benefit from there. Here is a list of some basic questions:

  • What are sessions ?
  • What is difference between session and cookie ?
  • What is a global and local varible ?
  • How do you set a constant in php ?
  • What is the difference between php4 and php5 ?

Cheers !!

Realin !

Share this post: