1. admin

  2. admin@psexam

  3. @psexam.com

  4. psexam.com


Correct Option: C
Explanation:

To solve this question, the user needs to know the basic syntax of the PHP programming language and the function of strstr().

strstr() function is used to find the first occurrence of a string inside another string. It returns a part of the haystack string starting from the first occurrence of the needle string to the end of the haystack string.

In the given script, the variable $email is assigned the string value of '[email protected]'. The strstr() function is called with two arguments: the $email variable and '@'. The function returns the first occurrence of '@' in the $email variable and assigns it to the variable $new. The print statement then outputs the value of $new.

Now, let's go through each option and explain why it is right or wrong:

A. admin: This option is incorrect because the strstr() function returns everything from the first occurrence of '@' to the end of the string. Therefore, the value of $new is '@psexam.com', not 'admin'.

B. admin@psexam: This option is incorrect because the strstr() function includes the needle string in the returned value. Therefore, the value of $new is '@psexam.com', not 'admin@psexam'.

C. @psexam.com: This option is correct. The strstr() function returns the first occurrence of '@' in the $email variable, which is '@psexam.com'. Therefore, the value of $new is '@psexam.com'.

D. psexam.com: This option is incorrect because the strstr() function returns the string starting from the first occurrence of '@'. Therefore, the returned value includes the '@' symbol. The value of $new is '@psexam.com', not 'psexam.com'.

The Answer is: C

Find more quizzes: