Summery Summery
Safe substring
Syntax Syntax
Parameters Parameters
- $str
-
(Required)
- $start
-
(Required)
- $length
-
(Optional)
Default value: null
Return Return
(string)
Source Source
File: wp-includes/sodium_compat/src/Core/Util.php
public static function substr($str, $start = 0, $length = null) { /* Type checks: */ if (!is_string($str)) { throw new TypeError('String expected'); } if ($length === 0) { return ''; } if (self::isMbStringOverride()) { if (PHP_VERSION_ID < 50400 && $length === null) { $length = self::strlen($str); } $sub = (string) mb_substr($str, $start, $length, '8bit'); } elseif ($length === null) { $sub = (string) substr($str, $start); } else { $sub = (string) substr($str, $start, $length); } if ($sub !== '') { return $sub; } return ''; }