Check if string exists in webpage

Hello!
how to check if a string exists in a webpage (current webpage)
I have tried this code but it doesn’t work

<?php
$contents = file_get_contents("https://www.mywebsite.com");
$search   ="gtag_report_conversion(url)";


if (strpos($contents, $search) === TRUE) {
    echo "<script>console.log('existant 99');</script>";
}
?>

Thanks in advance

strpos does not return true/false. It returns an integer.

EDIT: It returns false if it was NOT found. Otherwise it returns an integer.

or false :wink:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.