Str::startsWith PHP Method

startsWith() public static method

public static startsWith ( $haystack, $needle )
    public static function startsWith($haystack, $needle)
    {
        return 0 === strpos($haystack, $needle);
    }

Usage Example

Example #1
0
 /**
  * Gets the value of an environment variable. Supports boolean, empty and null.
  *
  * @param $key     string
  * @param $default mixed
  * @return mixed
  */
 function env($key, $default = null)
 {
     $value = getenv($key);
     if ($value === false) {
         return value($default);
     }
     switch (strtolower($value)) {
         case 'true':
         case '(true)':
             return true;
             break;
         case 'false':
         case '(false)':
             return false;
             break;
         case 'empty':
         case '(empty)':
             return '';
             break;
         case 'null':
         case '(null)':
             return;
             break;
         default:
             break;
     }
     if (strlen($value) > 1 && Str::startsWith($value, '"') && Str::endsWith($value, '"')) {
         return substr($value, 1, -1);
     }
     return $value;
 }
All Usage Examples Of Str::startsWith