Back to Opencart

File system\helper\general.php

docs/api/source-system.helper.general.html

4.1.0.34.6 KB
Original Source

Namespaces

Functions

| 1: | <?php | | 2: | // String | | 3: | function oc_strlen(string $string): int { | | 4: | return mb_strlen($string); | | 5: | } | | 6: | | | 7: | /** | | 8: | * @param string $string | | 9: | * @param string $needle | | 10: | * @param int $offset | | 11: | * | | 12: | * @return false|int | | 13: | */ | | 14: | function oc_strpos(string $string, string $needle, int $offset = 0) { | | 15: | return mb_strpos($string, $needle, $offset); | | 16: | } | | 17: | | | 18: | /** | | 19: | * @param string $string | | 20: | * @param string $needle | | 21: | * @param int $offset | | 22: | * | | 23: | * @return false|int | | 24: | */ | | 25: | function oc_strrpos(string $string, string $needle, int $offset = 0) { | | 26: | return mb_strrpos($string, $needle, $offset); | | 27: | } | | 28: | | | 29: | function oc_substr(string $string, int $offset, ?int $length = null): string { | | 30: | return mb_substr($string, $offset, $length); | | 31: | } | | 32: | | | 33: | function oc_strtoupper(string $string): string { | | 34: | return mb_strtoupper($string); | | 35: | } | | 36: | | | 37: | function oc_strtolower(string $string): string { | | 38: | return mb_strtolower($string); | | 39: | } | | 40: | | | 41: | // Other | | 42: | function oc_token(int $length = 32): string { | | 43: | return substr(bin2hex(random_bytes($length)), 0, $length); | | 44: | } | | 45: | | | 46: | // Pre PHP8 compatibility | | 47: | if (!function_exists('str_starts_with')) { | | 48: | function str_starts_with(string $string, string $find): bool { | | 49: | $substring = substr($string, strlen($find)); | | 50: | | | 51: | if ($substring === $find) { | | 52: | return true; | | 53: | } else { | | 54: | return false; | | 55: | } | | 56: | } | | 57: | } | | 58: | | | 59: | if (!function_exists('str_ends_with')) { | | 60: | function str_ends_with(string $string, string $find): bool { | | 61: | return substr($string, -strlen($find)) === $find; | | 62: | } | | 63: | } | | 64: | |

OpenCart API API documentation generated by ApiGen dev-master