Sr. PHP Programmer Question:
Download Questions PDF

How will you locate a string within a string in PHP?

Senior PHP Programmer Interview Question
Senior PHP Programmer Interview Question

Answer:

The strpos() function is used to search for a string or character within a string. If a match is found in the string, this function will return the position of the first match. If no match is found, it will return FALSE. Let's see if we can find the string "world" in our string −

<?php
echo strpos("Hello world!","world");
?>

This will produce following result −
6

Download Senior PHP Programmer Interview Questions And Answers PDF

Previous QuestionNext Question
How will you get the size of a file in php?What is the purpose of break statement?