What are the best practices for handling substring searches in PHP to ensure code readability and maintainability?

When handling substring searches in PHP, it's important to use clear and concise code to ensure readability and maintainability. One way to achieve this is by encapsulating the substring search logic in a separate function or method, making it easier to understand and reuse throughout the codebase.

// Encapsulate substring search logic in a separate function for readability and maintainability
function searchSubstring($haystack, $needle) {
    return strpos($haystack, $needle) !== false;
}

// Example usage
$haystack = "Hello, World!";
$needle = "World";
if (searchSubstring($haystack, $needle)) {
    echo "Substring found!";
} else {
    echo "Substring not found.";
}