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";
?>
<?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";
?>
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
Answer: Option C
Solution(By Examveda Team)
The code uses preg_match to check for a keyword and replies based on whether it is true (1) or false (0).Related Questions on Regular Expressions
A. 1 and 2
B. 2 and 4
C. 1 and 4
D. 2 and 3
Join The Discussion