ExamVeda
Login
Home
41
What will be the output of the following PHP code?
<?php
    echo ucwords("i love my country");
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
The ucwords() function converts the first character of each word in a string to uppercase.
42
What will be the output of the following PHP code?
<?php
    echo lcfirst("welcome to India");
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
The lcfirst() function converts the first character of a string to lowercase.
43
What will be the output of the following PHP code?
<?php
    echo hex2bin("48656c6c6f20576f726c6421");
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
The hex2bin() function converts a string of hexadecimal values to ASCII characters.
44
What will be the output of the following PHP code?
<?php 
    $str = addslashes('What does "yolo" mean?');
    echo($str); 
?>
Discuss
Answer & Solution
Answer: Option C
Solution:
The addslashes() function returns a string with backslashes in front of predefined characters.
45
What will be the output of the following PHP code?
<?php
    $str = "Hello world. It's a beautiful day.";
    print_r (explode(" ",$str));
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
The explode() function breaks a string into an array.
46
What will be the output of the following PHP code?
<?php
  echo strtr("Hilla Warld","ia","eo");
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
The strtr() function translates certain characters in a string.
47
What will be the output of the following PHP code?
<?php
    echo stripos("I love php, I love php too!","PHP");
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
The stripos() function finds the position of the first occurrence of a string inside another string.
48
What will be the output of the following PHP code ?
<?php
function A1($x)
{
  switch($x)
  {
  case 1: 
    //this statement is the same as if($x == 1)
    echo 'Case 1 was executed.';
    break;
  case 2: 
    //this statement is the same as if($x == 2)
    echo 'Case 2 was executed.';
    break;
  case 3: 
    //this statement is the same as if($x == 3)
    echo 'Case 3 was executed.';
    break;
  case 4: 
    //this statement is the same as if($x == 4)
    echo 'Case 4 was executed.';
    break;
  default: 
    //this statement is the same as if $x does not equal the other conditions
    echo 'Default was executed.';
    break;
  }
}
A1(9);
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
The switch statement is executed with $x = 9.
49
What will be the output of the following PHP code ?
<?php
    function uppercase($string)
    {
        echo ucwords($string);
    }
    $wow = "uppercase";
    $wow("Time to live king size");
?>
Discuss
Answer & Solution
Answer: Option D
Solution:
The ucwords() function converts the first character of each word in a string to uppercase.
50
What will be the output of the following PHP code ?
<?php
function TV($string)
{
    echo "my favourite TV show is ".$string;
    function b()
    {
       echo " I am here to spoil this code";
    }
}
b();
?>
Discuss
Answer & Solution
Answer: Option B
Solution:
b is undeclared if TV() is not called first.