What does the preg_match function return in PHP if no match is found?

If the preg_match function in PHP does not find a match, it returns 0. To check if a match is found, you can use a simple if statement to compare the result of preg_match with 0.

$subject = "Hello, World!";
$pattern = "/foo/";

if (preg_match($pattern, $subject) === 0) {
    echo "No match found.";
} else {
    echo "Match found!";
}