PHP Interview Questions part 1

1. Find the output of :

$a = rand(1,2);

if($a==0) {
echo “Red”;
else if($a>2) {
echo “White”;
else if($a) {
echo “Blue”;
else if($a=1) {
echo “Green”;
echo “Clear”;

a.) Red
b.) White
c.) Blue
d.) Green
e.) Clear

2. Find the output of :

echo substr(”artichoke”,-3,-2);

a.) ar
b.) ho
c.) rtic
d.) o
e.) oke

3. The PHP syntax is most similar to:

a.) VB Script
b.) P
erl and C
c.) .Net

4. What is the output of this PHP code?

$list = array(”clock”,”scissors”,”pen”,”yak”);
$list[] = “cow”;
$list[] = “dragon”;
print “$list[4]”;

a.) clock,scissors,pen,yak
b.) yak
c.) cow
d.) dragon
e.) pen

5. Find the output:

if ((string)’-1′)
print ‘ouch’;
print ‘echo’;

a.) None
b.) echo
c.) ouch

6. What is the out of this code?

if (is_float($x) == TRUE)
} printf(”%-02s$x”,$y);

a.) 003.14
b.) 003
c.) -02s3.14
d.) -33.14
e.) 303.14

7. In PHP, what is the output here?

$x = “”;
switch ($x) {
case “0″: echo “String”; break;
case 0: echo “Integer”; break;
case NULL: echo “NULL”; break;
case FALSE: echo “Boolean”; break;
case “”: echo “Empty string”; break;
default: echo “Something else”; break;

a.) String
b.) Integer
c.) NULL
d.) Boolean
e.) Empty string
f.) Something else

8. What is the output for:

$a=htmlspecialchars(”O\’Hare & Max was here!”);
echo substr_count($a,”&”);

a.) 5
b.) 8
c.) 1
d.) 0

9. What is the value of $y after execution:

do {
} while($x>0);

a.) 1
b.) 5
c.) 9
d.) 15
e.) 17


1. c.) Blue

2. d.) o

3. b.) Perl and C

4. c.) cow

5. c.) ouch

6. a.) 003.14

7. b.) Integer

8. c.) 1

9. e.) 17


3 Responses to “PHP Interview Questions part 1”

  1. Workers Injury Attorney Los Angeles Says:

    Highly energetic article, I liked that a lot. Will there be a part 2?

  2. cheapest lenders Says:

    Hi there to every body, it’s my first pay a visit of this web site; this blog includes amazing and really good stuff for visitors.

  3. shopping Says:

    Very quickly this web site will be famous amid all blogging and site-building
    viewers, due to it’s good articles or reviews

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: