My Report

PHP String Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. 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

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

    <?php
    $text = "this is\tsome text that\nwe might like to parse.";
    print_r(split("[\n\t]",$text));
    ?>

3. Which among the following is/are not a metacharacter?

i) \a
ii) \A
iii) \b
iv) \B

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

5. POSIX implementation was deprecated in which version of PHP?

6. PHP has long supported two regular expression implementations known as _______ and _______

i) Perl
ii) PEAR
iii) Pearl
iv) POSIX

7. POSIX stands for ____________

8. [:alpha:] can also be specified as ________

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

    <?php
    $username = "jasoN";
    if (ereg("([^a-z])",$username))
        echo "Username must be all lowercase!";
    else
        echo "Username is all lowercase!";
    ?>

10. Which one of the following regular expression matches any string containing zero or one p?


 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.