Home / CSE / PHP - CS :: Discussion

Discussion :: PHP - CS

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

    <?php

    $name = "What is your name?"

    if (preg_match("/name/"),$name)

    echo "My name is Will Pitt ";

    else

    echo "My name is not Will Pitt ";

    if (preg_match("/are/"))

    echo "I am great"

    else

    echo "I am not great";

    ?>

  2. A.

     My name is Will Pitt I am great

    B.

     My name is not Will Pitt I am great

    C.

     My name is Will Pitt I am not great

    D.

     My name is not Will Pitt I am not great

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    The code uses preg_match to check for a keyword and replies based on whether it is true (1) or false (0).


Be The First To Comment