Home / PHP Tips Generated By ChatGPT / Checking If a String Ends With a Specific Text in PHP PHP 8 introduced str_ends_with() for this purpose. Source Code if (str_ends_with('Hello, World!', 'World!')) { echo "String ends with 'World!'."; }