str_contains Online
Test PHP's str_contains() function online using real PHP 8.2. Check if a string contains a substring. Case-sensitive search introduced in PHP 8.0.
str_contains(string $haystack, string $needle): bool Returns true if needle is found in haystack, false otherwise. Case-sensitive.
Haystack (String to Search In)
Enter the string you want to search
Needle (Substring to Find)
Enter the substring you're looking for
PHP Code
This is the actual PHP code that will be executed
Common Examples
str_contains() Function Guide
About str_contains()
This tool runs actual PHP 8.2 code on our server using Docker containers. The str_contains() function was introduced in PHP 8.0 as a modern, intuitive way to check if a substring exists within a string. It's case-sensitive and returns a boolean.
- Returns true if needle is found
- Returns false if not found
- Case-sensitive search
- Works with empty strings (always returns true)
- Simpler than strpos() !== false
Related Functions
str_starts_with()- Check if string starts with substringstr_ends_with()- Check if string ends with substringstripos()- Case-insensitive positionstrpos()- Case-sensitive position
💡 Tip: For case-insensitive search, use:str_contains(strtolower($haystack), strtolower($needle))
Request a Feature
Have an idea to improve this tool? Share your suggestions and help us make it better! (One request per day)

