PHP String MCQs

11. Predict the output of the following code snippet :

<?php
$str="chess was played";
echo strlen(substr($str,3,2))."
"
?>

A. 1
B. 2
C. 3
D. Array

View Answer


12. Predict the output of the following code snippet :

<?php
echo count_chars("AA",1);
?>

A. 2
B. [65]=>2
C. Array
D. None of the above

View Answer


13. A variable $str is set to "HELLO WORLD", which of the following script returns it title case?

A. echo ucwords($str)
B. echo ucwords(strtolower($str)
C. echo ucfirst($str)
D. echo ucfirst(strtolower($str)

View Answer


14. The PHP function searches for a specific text within a string.

A. strpos()
B. strposition()
C. strrev()
D. str_replace()

View Answer


15. Which function is used to Calculate a 32-bit CRC for a string?

A. crc32()
B. crypt()
C. heb32()
D. heb32c()

View Answer


16. What is the use of htmlentities() function in php?

A. Converts characters to HTML entities
B. Converts HTML entities to characters
C. Converts some predefined HTML entities to characters
D. Converts some predefined characters to HTML entities

View Answer


17. How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.

A. 7
B. 8
C. 9
D. 10

View Answer


18. What will be the output of the following PHP code?

<?php 
    $title = "O malley wins the heavyweight championship!";
    echo ucwords($title);
?>

A. O Malley Wins The Heavyweight Championship!
B. O malley Wins The Heavyweight Championship!
C. O Malley wins the heavyweight championship!
D. o malley wins the heavyweight championship!

View Answer


19. What will be the output of the following PHP code?

<?php 
   $url = "lfc123456@example.com";
   echo ltrim(strstr($url, "@"),"@");
?>

A. lfc123456@example.com
B. lfc123456
C. lfc123456@
D. example.com

View Answer


20. How many functions does PHP offer for searching strings using POSIX style regular expression?

A. 7
B. 8
C. 9
D. 10

View Answer





Discussion


* You must be logged in to add comment.