PHP Strings Quiz Questions and Answers

Multiple Choice Questions on PHP Strings with Functions and Examples. You can download PDF of PHP Strings MCQ questions as One Word or as Questions Paper absolutely free.
1. What is the output of the following code snippet?

$str = 'asdfghyo off on off';
$replace_pairs = array('a' => 'q', 's' => 'w', 'd' => 'e', 'f' => 'r', 'y' => 'z', 'o' => 'i', 'off' => 'on', 'on' => 'off');
echo strtr($str, $replace_pairs);
[A] Qwerghzi on off on
[B] Qwerghzo on off on
[C] Qwerghzi on on on
[D] Qwerghzi off off off
Loading...
2. What is the output of the following code snippet?


echo stristr('PHPzphpZPHPZfoo', 'Z');
[A] ZphpZPHPZfoo
[B] ZPHPZfoo
[C] Zphpzphpzfoo
[D] PhpZPHPZfoo
Loading...
3. What is the output of the following script?


echo strlen('foo' . chr(0) . '1'), ', ', strlen(0x00);
[A] 5, 1
[B] 3, 0
[C] 3, 4
[D] 5, 0
[E] 4, 0
Loading...
4. What is the function of the ucfirst and lcfirst functions?
[A] To make the string's first character uppercase or lowercase, respectively.
[B] To make the string's first word uppercase or lowercase, respectively.
Loading...
5. What is the output of the following?

echo strcmp('first', 'second'), ", ";
echo strcmp('44', '054'), ", ";
echo strcmp('0x80', 'a'), ", ";
echo strcmp('a', 'A');
[A] -1, 1, -1, 1
[B] -1, 0, -1, 1
[C] 1, 0, 1, -1
[D] -1, -1, -1, -1
[E] -1, -1, 1, -1
Loading...
Are these questions helpful for you?

PHP Strings Programs/Functions


Comments: (Your feedback is valuable to us)
KBC Questions and Answers