PHP

PHP

Basics has 30 Questions

What does PHP stand for? i) Personal Home Page ii) Hypertext Preprocessor iii) Pretext Hypertext Processor iv) Preprocessor Home Page

Both i) and iii)
Both ii) and iv)
Only ii)
Both i) and ii)
PHP files have a default file extension of..

.html
.xml
.php
.ph
Which of the following is/are a PHP code editor? i) Notepad ii) Notepad++ iii) Adobe Dreamweaver iv) PDT

Only iv)
All of the mentioned.
i), ii) and iii)
Only iii)
Which of the following must be installed on your computer so as to run PHP script? i) Adobe Dreamweaver ii) PHP iii) Apache iv) IIS

All of the mentioned.
Only ii)
ii) and iii)
ii), iii) and iv)
Which version of PHP introduced Try/catch Exception?

HP 4
b)PHP 5
c)PHP 5.3
d)PHP 6
We can use ___ to comment a single line? i) /? ii) // iii) # iv) /* */

Only ii)
i), iii) and iv)
ii), iii) and iv)
Both ii) and iv)
Which of the following php statement/statements will store 111 in variable num? i) int $num = 111; ii) int mum = 111; iii) $num = 111; iv) 111 = $num;

Both i) and ii)
All of the mentioned.
Only iii)
Only i)
What will be the output of the following php code?
  1.     <?php
  2.     $num  = 1;
  3.     $num1 = 2;
  4.     print $num . "+". $num1;
  5.     ?>

3
1+2
1.+.2
Error
What will be the output of the following php code?
  1.     <?php
  2.     $num  = "1";
  3.     $num1 = "2";
  4.     print $num+$num1;
  5.     ?>

3
1+2
Error
12
A PHP script should start with ___ and end with ___:

< php >
< ? php ?>
<? ?>
<?php ?>
Which of following variables can be assigned a value to it? i) $3hello ii) $_hello iii) $this iv) $This

All of the mentioned
Only ii)
ii), iii) and iv)
ii) and iv)
What will be the output of the following code?
  1.     <?php
  2.     $foo = 'Bob';              
  3.     $bar = &$foo;              
  4.     $bar = "My name is $bar";  
  5.     echo $bar;
  6.     echo $foo;
  7.     ?>

Error
My name is BobBob
My name is BobMy name is Bob
My name is Bob Bob

Which of the following PHP statements will output Hello World on the screen?

i) $3hello
ii) $_hello
iii) $this
iv) $This


i) and ii)
i), ii) and iii)
All of the mentioned
i), ii) and iv)
What will be the output of the following PHP code?
  1.     <?php
  2.     $color = "maroon";
  3.     $var = $color[2];
  4.     echo "$var";
  5.     ?>

a
Error
$var
r
What will be the output of the following PHP code?
  1.     <?php
  2.     $score = 1234;
  3.     $scoreboard = (array) $score;
  4.     echo $scoreboard[0];
  5.     ?>

1
Error
1234
2
What will be the output of the following PHP code?
  1.     <?php
  2.     $total = "25 students";
  3.     $more = 10;
  4.     $total = $total + $more;
  5.     echo "$total";
  6.     ?>

Error
35 students
35
25 students
Which of the below statements is equivalent to $add += $add ?

$add = $add
$add = $add +$add
$add = $add + 1
$add = $add + $add + 1
Which statement will output $x on the screen?

echo "\$x";

echo "$$x";
echo "/$x";

echo "$x;";

What will be the output of the following code?
  1.     <?php
  2.     function track() {
  3.     static $count = 0;
  4.     $count++;
  5.     echo $count;
  6.     }
  7.     track();
  8.     track();
  9.     track();
  10.     ?>

123
111
000
011
What will be the output of the following PHP code?
  1.     <?php
  2.     $a = "clue";
  3.     $a .= "get";
  4.     echo "$a";
  5.     ?>

get
true
false
clueget
What will be the output of the following PHP code?
  1.     <?php
  2.     $a = 5;
  3.     $b = 5;
  4.     echo ($a === $b);
  5.     ?>

5 === 5
Error
1
False
Which of the below symbols is a newline character?

\r
\n
/n
/r
What will be the output of the following PHP code?
  1.     <?php
  2.     $num = 10;
  3.     echo 'What is her age? \n She is $num years old';
  4.     ?>

What is her age? \n She is $num years old

What is her age?

She is $num years old

What is her age? She is 10 years old

What is her age?

She is 10 years old

Which of the conditional statements is/are supported by PHP? i) if statements ii) if-else statements iii) if-elseif statements iv) switch statements

Only i)
i), ii) and iv)
ii), iii) and iv)
All of the mentioned.
What will be the output of the following PHP code?
  1.     <?php
  2.     $team = "arsenal";
  3.     switch ($team) {
  4.     case "manu":
  5.         echo "I love man u";
  6.     case "arsenal":
  7.         echo "I love arsenal";
  8.     case "manc":
  9.         echo "I love manc"; }
  10.     ?>

I love arsenal
Error
I love arsenalI love manc
I love arsenalI love mancI love manu
Which of the looping statements is/are supported by PHP? i) for loop ii) while loop iii) do-while loop iv) foreach loop

i) and ii)
i), ii) and iii)
All of the mentioned
None of the mentioned
What will be the output of the following PHP code?
  1.     <?php
  2.     $user = array("Ashley", "Bale", "Shrek", "Blank");
  3.     for ($x=0; $x < count($user); $x++)	{
  4.         if ($user[$x] == "Shrek") continue;
  5.             printf ($user[$x]); 
  6.     }
  7.     ?>

AshleyBale
AshleyBaleBlank
ShrekBlank
Shrek
If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

12
1
Error
5
What is the value of $a and $b after the function call?
  1.     <?php
  2.     function doSomething( &$arg ) {
  3.         $return = $arg;
  4.         $arg += 1;
  5.         return $return;	
  6.     }
  7.     $a = 3;
  8.     $b = doSomething( $a );
  9.     ?>

a is 3 and b is 4.
a is 4 and b is 3.
Both are 3.
Both are 4.
Who is the father of PHP?

Rasmus Lerdorf
Willam Makepiece
Drek Kolkevi
List Barely