PHP

PHP

Strings and Regular Expressions has 15 Questions

PHP has long supported two regular expression implementations known as ___ and ___. i) Perl ii) PEAR iii) Pearl iv) POSIX

i) and ii)
ii) and iv)
i) and iv)
ii) and iii)
Which one of the following regular expression matches any string containing zero or one p?

p+
p*
P?
p#
[:alpha:] can also be specified as..

[A-Za-z0-9]
[A-za-z]
[A-z]
[a-z]
How many functions does PHP offer for searching strings using POSIX style regular expression?

7
8
9
10
POSIX implementation was deprecated in which version of PHP?

PHP 4
PHP 5
PHP 5.2
PHP 5.3
POSIX stands for

Portable Operating System Interface for Unix
Portable Operating System Interface for Linux
Portative Operating System Interface for Unix
Portative Operating System Interface for Linux
Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/ ? i) fol ii) fool iii) fooool iv) fooooool

Only i)
ii) and iii)
i), iii) and iv)
i) and iv)
How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.

7
8
9
10
What will be the output of the following PHP code?
  1.     <?php
  2.     $foods = array("pasta", "steak", "fish", "potatoes");
  3.     $food = preg_grep("/^s/", $foods);
  4.     print_r($food);
  5.     ?>

Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )
Array ( [3] => potatoes )
Array ( [1] => steak )
Array ( [0] => potatoes )
Which one of the following functions will convert a string to all uppercase?

strtoupper()
uppercase()
str_uppercase()
struppercase()
What will be the output of the following PHP code?
  1.     <?php
  2.     echo str_pad("Salad", 5)." is good.";
  3.     ?>

SaladSaladSaladSaladSalad is good
is good SaladSaladSaladSaladSalad
is good Salad
Salad is good
Which one of the following functions can be used to concatenate array elements to form a single delimited string?

explode()
implode()
concat()
concatenate()
Which one of the following functions finds the last occurrence of a string, returning its numerical position?

strlastpos()
strpos()
strlast()
strrpos()
What will be the output of the following PHP code?
  1.     <?php
  2.     $url = "nachiketh@example.com";
  3.     echo ltrim(strstr($url, "@"),"@");
  4.     ?>

nachiketh@example.com
nachiketh
nachiketh@
example.com
What will be the output of the following PHP code?
  1.     <?php
  2.     $text = "this is\tsome text that\nwe might like to parse.";
  3.     print_r(split("[\n\t]",$text));
  4.     ?>

this is some text that we might like to parse.
Array ( [0] => some text that [1] => we might like to parse. )
Array ( [0] => this is [1] => some text that [2] => we might like to parse. )
[0] => this is [1] => some text that [2] => we might like to parse.