WordPress开发者和主题制作者的搜索引擎



randomcompat_substr ›

Sincen/a
已弃用n/a
randomcompat_substr ( $binary_string, $start, $length = null )
参数: (3)
  • (string) $binary_string
    Required: Yes
  • (int) $start
    Required: Yes
  • (int) $length (optional)
    Required: No
    默认: null
返回:
  • (string)
定义在:
文档:

substr() implementation that isn't brittle to mbstring.func_overload

This version just uses the default substr()



源码

function RandomCompat_substr($binary_string, $start, $length = null)
        {
            if (!is_string($binary_string)) {
                throw new TypeError(
                    'RandomCompat_substr(): First argument should be a string'
                );
            }

            if (!is_int($start)) {
                throw new TypeError(
                    'RandomCompat_substr(): Second argument should be an integer'
                );
            }

            if ($length !== null) {
                if (!is_int($length)) {
                    throw new TypeError(
                        'RandomCompat_substr(): Third argument should be an integer, or omitted'
                    );
                }

                return (string) substr($binary_string, $start, $length);
            }

            return (string) substr($binary_string, $start);
        }
    }
}