# yatra/trunk/includes/php-compat.php

Yatra – Travel Booking &amp; Tour Operator Software, version trunk. 36 lines.

- Page: https://pluginprobe.com/plugins/yatra/trunk/code/includes/php-compat.php
- Raw: https://pluginprobe.com/plugins/yatra/trunk/raw/includes/php-compat.php
- Modified: 2026-04-14T03:47:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/yatra/trunk/code/includes/php-compat.php#L10-L20`.

```php
<?php
/**
 * Polyfills for PHP 8 string helpers when running on PHP 7.4.
 * WordPress core also defines these when missing; this file is a no-op if they already exist.
 */

if (!function_exists('str_contains')) {
    /**
     * @param string $haystack
     * @param string $needle
     */
    function str_contains($haystack, $needle)
    {
        if ($needle === '') {
            return true;
        }

        return strpos((string) $haystack, (string) $needle) !== false;
    }
}

if (!function_exists('str_starts_with')) {
    /**
     * @param string $haystack
     * @param string $needle
     */
    function str_starts_with($haystack, $needle)
    {
        if ($needle === '') {
            return true;
        }

        return strncmp((string) $haystack, (string) $needle, strlen((string) $needle)) === 0;
    }
}

```
