Documentation ¶
Overview ¶
PHP built-in function library with Go language
Index ¶
- Constants
- Variables
- func Abs(number float64) float64
- func Acos(x complex128) complex128
- func Acosh(x complex128) complex128
- func Addcslashes(s string, c byte) string
- func Addslashes(str string) string
- func Array(v ...interface{}) []interface{}
- func ArrayChangeKeyase(arrayOrigin map[string]interface{}, changeTo int) map[string]interface{}
- func ArrayChunk(s []interface{}, size int) [][]interface{}
- func ArrayColumn(arrayMap map[string]map[string]interface{}, columnKey string) (r []interface{})
- func ArrayColumnMapStringStringRetArrayString(array []map[string]string, column string) []string
- func ArrayColumnRetArrayString(array []map[string]interface{}, column string) []string
- func ArrayCombine(s1, s2 []interface{}) map[interface{}]interface{}
- func ArrayCountValues(s []interface{}) map[interface{}]uint
- func ArrayDiff(array1, array2 []interface{}) []interface{}
- func ArrayFill(startIndex int, num uint, value interface{}) map[int]interface{}
- func ArrayFillKeys(keys []interface{}, value interface{}) map[interface{}]interface{}
- func ArrayFlip(arrayMap map[interface{}]interface{}) map[interface{}]interface{}
- func ArrayIntersect(nums1, nums2 []int) []int
- func ArrayKeyExists(key interface{}, m map[interface{}]interface{}) bool
- func ArrayKeyExistsString(needle string, haystack map[string]interface{}) bool
- func ArrayKeyFirst(array map[interface{}]interface{}) interface{}
- func ArrayKeyLast(arr map[interface{}]interface{}) interface{}
- func ArrayKeys(elements map[interface{}]interface{}) []interface{}
- func ArrayKeysInt(array map[int]interface{}) []int
- func ArrayKeysInterface(array map[interface{}]interface{}) []interface{}
- func ArrayMerge(ss ...[]interface{}) []interface{}
- func ArrayMergeString(arr1, arr2 []string) []string
- func ArrayPad(s []interface{}, size int, val interface{}) []interface{}
- func ArrayPop(s *[]interface{}) interface{}
- func ArrayPush(s *[]interface{}, elements ...interface{}) int
- func ArrayRand(elements []interface{}) []interface{}
- func ArrayReverse(s []interface{}) []interface{}
- func ArraySearch(needle interface{}, haystack []interface{}) int
- func ArraySearchString(needle string, haystack []string) int
- func ArrayShift(s *[]interface{}) interface{}
- func ArraySlice(s []interface{}, offset, length uint) []interface{}
- func ArrayUnshift(s *[]interface{}, elements ...interface{}) int
- func ArrayValues(elements map[interface{}]interface{}) []interface{}
- func Asin(x complex128) complex128
- func Asinh(x complex128) complex128
- func Atan(x complex128) complex128
- func Atan2(y, x float64) float64
- func Atanh(x complex128) complex128
- func Base64Decode(s string) (string, error)
- func Base64Encode(s string) string
- func BaseConvert(num string, frombase, tobase int) (string, error)
- func Basename(path string) string
- func Bin2hex(str string) (string, error)
- func Bindec(str string) (string, error)
- func Boolval(val interface{}) bool
- func CamelStringToUnderline(s string) string
- func Ceil(x float64) float64
- func Chdir(dir string) error
- func Checkdate(month, day, year uint) bool
- func Chgrp(name string, uid, gid int) error
- func Chmod(filename string, mode os.FileMode) bool
- func Chown(filename string, uid, gid int) bool
- func Chr(ascii int) string
- func ChunkSplit(str string, chunkLen int, end string) string
- func Closedir(fd int) (err error)
- func Copy(source, dest string) (bool, error)
- func Cos(x float64) float64
- func Cosh(x float64) float64
- func Count(v []interface{}) int
- func Crc32(str string) uint32
- func Date(timestamp int64) string
- func DateAdd(t time.Time, years int, months int, days int) time.Time
- func DateAfter(seconds int64, timestamp int64) string
- func DateBefore(seconds int64, timestamp int64) string
- func DateDaysafter(days int64, timestamp int64) string
- func DateDaysbefore(days int64, timestamp int64) string
- func DateHoursafter(hours int64, timestamp int64) string
- func DateHoursbefore(hours int64, timestamp int64) string
- func DateMinutesbefore(minutes int64, timestamp int64) string
- func DateNow() string
- func DateToday() string
- func DateTomorrow() string
- func Date_minutesafter(minutes int64, timestamp int64) string
- func Datetime(timestamp int64) string
- func DatetimeAfter(seconds int64, timestamp int64) string
- func DatetimeBefore(seconds int64, timestamp int64) string
- func DatetimeDaysafter(days int64, timestamp int64) string
- func DatetimeDaysbefore(days int64, timestamp int64) string
- func DatetimeHoursafter(hours int64, timestamp int64) string
- func DatetimeHoursbefore(hours int64, timestamp int64) string
- func DatetimeMinutesafter(minutes int64, timestamp int64) string
- func DatetimeMinutesbefore(minutes int64, timestamp int64) string
- func DatetimeNow() string
- func DatetimeToday() string
- func DatetimeTomorrow() string
- func Decbin(x int64) string
- func Dechex(x int64) string
- func Decoct(x int64) string
- func Delete(filename string) error
- func Die(status int)
- func Dirname(dirPth string) ([]os.FileInfo, error)
- func DiskFreeSpace(directory string) (uint64, error)
- func DiskTotalSpace(directory string) (uint64, error)
- func Echo(args ...interface{})
- func Empty(v interface{}) bool
- func Exec(command string, output *[]string, returnVar *int) string
- func Exit(status int)
- func Exp(x float64) float64
- func Explode(delimiter, str string) []string
- func Expm1(x float64) float64
- func Fclose(handle *os.File) error
- func Fgetcsv(handle *os.File, length int, delimiter rune) ([][]string, error)
- func FileExists(filename string) bool
- func FileExits(path string) bool
- func FileExitsDetail(path string) (bool, error)
- func FileGetContents(filename string) (string, error)
- func FilePutContents(filename string, data string, mode os.FileMode) error
- func FileSize(filename string) (int64, error)
- func Filemtime(filename string) (int64, error)
- func Floor(x float64) float64
- func GetENV() (env string)
- func GetHtmlTranslationTable() map[string]string
- func GetIpInfo(ip string) string
- func Getcwd() (string, error)
- func Getenv(varname string) string
- func Gethostbyaddr(ipAddress string) (string, error)
- func Gethostbyname(hostname string) (string, error)
- func Gethostbynamel(hostname string) ([]string, error)
- func Gethostname() (string, error)
- func Gettype(v interface{}) string
- func Glob(pattern string) (matches []string, err error)
- func HTMLEntityDecode(str string) string
- func HTTPBuildQuery(queryData url.Values) string
- func Hex2bin(data string) (string, error)
- func Hexdec(str string) (int64, error)
- func HtmlEntityDecode(str string) string
- func Htmlentities(str string) string
- func Htmlspecialchars(s string) string
- func HtmlspecialcharsDecode(s string) string
- func IP2long(ipAddress string) uint32
- func Implode(glue string, pieces []string) string
- func InArray(needle interface{}, haystack interface{}) bool
- func Intval(str string) (int, error)
- func IsBool(v interface{}) bool
- func IsDir(filename string) (bool, error)
- func IsFile(filename string) bool
- func IsFinite(f float64, sign int) bool
- func IsInfinite(f float64, sign int) bool
- func IsNan(f float64) bool
- func IsNumeric(x interface{}) (result bool)
- func IsReadable(filename string) bool
- func IsWritable(name string) bool
- func IsWriteable(filename string) bool
- func JSONDecode(data []byte, val interface{}) error
- func JSONEncode(val interface{}) ([]byte, error)
- func Join(a []string, sep string) string
- func JsonDecode(data []byte, v interface{}) error
- func JsonEncode(v interface{}) ([]byte, error)
- func Lcfirst(str string) string
- func Levenshtein(str1, str2 string, costIns, costRep, costDel int) int
- func Log(x float64) float64
- func Log10(x float64) float64
- func Log1p(x float64) float64
- func Long2ip(properAddress uint32) string
- func Ltrim(str string, characterMask ...string) string
- func MapCamelStringToUnderline(body map[string]interface{}) map[string]interface{}
- func MapMerge(arr1, arr2 map[string]interface{}) map[string]interface{}
- func MapMergeKeyInterface(arr1, arr2 map[interface{}]interface{}) map[interface{}]interface{}
- func MapMergeString(arr1, arr2 map[string]string) map[string]string
- func MapUnderlineStringToCamel(body map[string]interface{}) map[string]interface{}
- func Max(nums ...float64) float64
- func MbStrlen(s string) int
- func MbSubstr(s string, start int, length ...int) string
- func Md5(s string) string
- func Md5File(path string) (string, error)
- func MemoryGetUsage(realUsage bool) uint64
- func Min(nums ...float64) float64
- func Mkdir(filename string, mode os.FileMode) error
- func MkdirAll(filename string, mode os.FileMode) error
- func Nl2br(str string, isXhtml bool) string
- func NumberFormat(number float64, decimals uint, decPoint, thousandsSep string) string
- func Octdec(str string) (int64, error)
- func Ord(char string) int
- func Pack(order binary.ByteOrder, data interface{}) (string, error)
- func ParseStr(encodedString string, result map[string]interface{}) error
- func ParseURL(str string, component int) (map[string]string, error)
- func ParseUrl(rawurl string) (*url.URL, error)
- func Passthru(command string, returnVar *int)
- func Pathinfo(path string, options int) map[string]string
- func Pi() float64
- func Pow(x, y float64) float64
- func Print(v interface{})
- func PrintR(v interface{})
- func Putenv(setting string) error
- func Quotemeta(str string) string
- func Rand(min, max int) int
- func Rawurldecode(s string) (string, error)
- func Rawurlencode(s string) string
- func Realpath(path string) (string, error)
- func Rename(oldpath, newpath string) error
- func Rmdir(path string) error
- func Round(x float64) float64
- func Rtrim(str string, characterMask ...string) string
- func Scandir(dirname string) ([]os.FileInfo, error)
- func Sha1(s string) string
- func Sha1File(path string) (string, error)
- func SimilarText(first, second string, percent *float64) int
- func Sin(x float64) float64
- func Sinh(x float64) float64
- func Sleep(s int64)
- func Soundex(str string) string
- func Sqrt(x float64) float64
- func Stat(name string) (os.FileInfo, error)
- func StrPad(s string, length int, args ...string) string
- func StrRepeat(s string, count int) string
- func StrReplace(search, replace, subject string, count int) string
- func StrShuffle(str string) string
- func StrToTime(strtime interface{}) int64
- func StrToTimeDate(strtime interface{}) int64
- func StrToTimeDateTime(strtime interface{}) int64
- func StrWordCount(str string) []string
- func Stringval(value interface{}) string
- func StripTags(s string) string
- func Stripos(haystack, needle string, offset int) int
- func Stripslashes(str string) string
- func Strlen(s string) int
- func Strpos(haystack, needle string, offset int) int
- func Strrchr(s, substr string) string
- func Strrev(str string) string
- func Strripos(haystack, needle string, offset int) int
- func Strrpos(haystack, needle string, offset int) int
- func Strstr(haystack string, needle string) string
- func Strtolower(str string) string
- func Strtotime(format, strtime string) (int64, error)
- func Strtoupper(str string) string
- func Strtr(haystack string, params ...interface{}) string
- func Strval(val interface{}) string
- func Substr(str string, start uint, length int) string
- func SubstrCompare(main_str, str string, offset, length int) int
- func SubstrCount(s, substr string) int
- func SysGetTempDir() string
- func System(command string, returnVar *int) string
- func Tan(x float64) float64
- func Tanh(x float64) float64
- func Ternary(condition bool, trueVal, falseVal interface{}) interface{}
- func Time() int64
- func Touch(filename string) (bool, error)
- func Trim(str string, characterMask ...string) string
- func URLDecode(str string) (string, error)
- func URLEncode(str string) string
- func Ucfirst(str string) string
- func Ucwords(str string) string
- func Umask(mask int) int
- func UnderlineStringToCamel(s string) string
- func Uniqid(prefix string) string
- func Unlink(name string) error
- func Unpack(order binary.ByteOrder, data string) (interface{}, error)
- func Urldecode(s string) (string, error)
- func Urlencode(s string) string
- func Usleep(ms int64)
- func VersionCompare(version1, version2, operator string) bool
- func Wordwrap(str string, width uint, br string, cut bool) string
- func ZipOpen(filename string) (*zip.ReadCloser, error)
Constants ¶
const ( StrPadRight = "STR_PAD_RIGHT" StrPadLeft = "STR_PAD_LEFT" )
Constants for StrPad
Variables ¶
var ( FORMAT_DATE string = "2006-01-02" FORMAT_DATETIME string = "2006-01-02 15:04:05" CASE_UPPER int = 1 //转为大写 CASE_LOWER int = 0 //转为小写 RET_STRING = 0 //结果为STRING RET_INT = 1 //结果为INT RET_INT64 = 2 //结果为INT64 )
Functions ¶
func Addcslashes ¶
Addcslashes - Quote string with slashes in a C style
func ArrayChangeKeyase ¶ added in v1.0.3
func ArrayChunk ¶
func ArrayChunk(s []interface{}, size int) [][]interface{}
ArrayChunk array_chunk()
func ArrayColumn ¶
ArrayColumn array_column() ArrayColumn — Return the values from a single column in the input array
func ArrayColumnMapStringStringRetArrayString ¶ added in v1.0.3
func ArrayColumnRetArrayString ¶ added in v1.0.3
func ArrayCombine ¶
func ArrayCombine(s1, s2 []interface{}) map[interface{}]interface{}
ArrayCombine array_combine()
func ArrayCountValues ¶
func ArrayCountValues(s []interface{}) map[interface{}]uint
ArrayCountValues — Counts all the values of an array
func ArrayFillKeys ¶
func ArrayFillKeys(keys []interface{}, value interface{}) map[interface{}]interface{}
ArrayFillKeys - Fill an array with values, specifying keys
func ArrayFlip ¶
func ArrayFlip(arrayMap map[interface{}]interface{}) map[interface{}]interface{}
ArrayFlip - Exchanges all keys with their associated values in an array
func ArrayIntersect ¶
ArrayIntersect — Computes the intersection of arrays
func ArrayKeyExists ¶
func ArrayKeyExists(key interface{}, m map[interface{}]interface{}) bool
ArrayKeyExists array_key_exists()
func ArrayKeyExistsString ¶ added in v1.0.3
func ArrayKeyFirst ¶ added in v1.0.3
func ArrayKeyFirst(array map[interface{}]interface{}) interface{}
*
- array_key_first — Gets the first key of an array
- @params map[interface{}]interface{} array An array. *
- @return interface{}
func ArrayKeyLast ¶ added in v1.0.3
func ArrayKeyLast(arr map[interface{}]interface{}) interface{}
*
- array_key_first — Gets the first key of an array
- @params map[interface{}]interface{} array An array. *
- @return interface{}
func ArrayKeys ¶
func ArrayKeys(elements map[interface{}]interface{}) []interface{}
ArrayKeys array_keys()
func ArrayKeysInterface ¶ added in v1.0.3
func ArrayKeysInterface(array map[interface{}]interface{}) []interface{}
key的类型为interface{}
func ArrayMergeString ¶ added in v1.0.3
对于切片不建议使用本方法,而要直接使用 append
func ArrayPad ¶
func ArrayPad(s []interface{}, size int, val interface{}) []interface{}
ArrayPad array_pad()
func ArrayPop ¶
func ArrayPop(s *[]interface{}) interface{}
ArrayPop array_pop() Pop the element off the end of slice
func ArrayPush ¶
func ArrayPush(s *[]interface{}, elements ...interface{}) int
ArrayPush - Push one or more elements onto the end of array
func ArraySearch ¶ added in v1.0.3
func ArraySearch(needle interface{}, haystack []interface{}) int
func ArraySearchString ¶ added in v1.0.3
func ArrayShift ¶
func ArrayShift(s *[]interface{}) interface{}
ArrayShift array_shift() Shift an element off the beginning of slice
func ArraySlice ¶
func ArraySlice(s []interface{}, offset, length uint) []interface{}
ArraySlice array_slice()
func ArrayUnshift ¶
func ArrayUnshift(s *[]interface{}, elements ...interface{}) int
ArrayUnshift array_unshift() Prepend one or more elements to the beginning of a slice
func ArrayValues ¶
func ArrayValues(elements map[interface{}]interface{}) []interface{}
ArrayValues array_values()
func Base64Decode ¶
Base64Decode - Decodes data encoded with MIME base64
func BaseConvert ¶
BaseConvert - Convert a number between arbitrary bases
func CamelStringToUnderline ¶ added in v1.0.3
*
驼峰字符串转成下划线+小些字母 例如: abcdAccc ==> abcd_accc AbcdA ==> abcd_a 如果遇到有大写字母的地方,则将在前一位将加上下划线 "_", 将大写字母转成小字母(如果是首字母,则只是转成小谢即可)
func ChunkSplit ¶
ChunkSplit - Split a string into smaller chunks
func Count ¶
func Count(v []interface{}) int
Count - Count all elements in an array, or something in an object
func DateAdd ¶
DateAdd - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object
func DateHoursafter ¶ added in v1.0.3
多少小时后
func DateHoursbefore ¶ added in v1.0.3
多少小时前
func DateMinutesbefore ¶ added in v1.0.3
多少分钟前
func Date_minutesafter ¶ added in v1.0.3
多少分钟后
func DatetimeBefore ¶ added in v1.0.3
多少秒前
func DatetimeDaysafter ¶ added in v1.0.3
多少天后
func DatetimeDaysbefore ¶ added in v1.0.3
多少天前
func DatetimeHoursafter ¶ added in v1.0.3
多少小时后
func DatetimeHoursbefore ¶ added in v1.0.3
多少小时前
func DatetimeMinutesafter ¶ added in v1.0.3
多少分钟后
func DatetimeMinutesbefore ¶ added in v1.0.3
多少分钟前
func DiskFreeSpace ¶
DiskFreeSpace disk_free_space()
func DiskTotalSpace ¶
DiskTotalSpace disk_total_space()
func Expm1 ¶
Expm1 - Returns exp(number) - 1 computed in a way that is accurate even when the value of number is close to zero
func FileExitsDetail ¶ added in v1.0.3
func FileGetContents ¶
FileGetContents file_get_contents()
func FilePutContents ¶
FilePutContents file_put_contents()
func GetHtmlTranslationTable ¶
GetHtmlTranslationTable - Returns the translation table used by htmlspecialchars() and htmlentities()
func Gethostbyaddr ¶
Gethostbyaddr gethostbyaddr() Get the Internet host name corresponding to a given IP address
func Gethostbyname ¶
Gethostbyname gethostbyname() Get the IPv4 address corresponding to a given Internet host name
func Gethostbynamel ¶
Gethostbynamel gethostbynamel() Get a list of IPv4 addresses corresponding to a given Internet host name
func HTMLEntityDecode ¶
HTMLEntityDecode html_entity_decode()
func HTTPBuildQuery ¶
HTTPBuildQuery http_build_query()
func HtmlEntityDecode ¶ added in v1.0.3
func Htmlspecialchars ¶
Htmlspecialchars - Convert special characters to HTML entities
func HtmlspecialcharsDecode ¶
HtmlspecialcharsDecode - Convert special HTML entities back to characters
func InArray ¶
func InArray(needle interface{}, haystack interface{}) bool
InArray in_array() haystack supported types: slice, array or map
func IsInfinite ¶
IsInfinite - Finds whether a value is infinite
func IsNumeric ¶
func IsNumeric(x interface{}) (result bool)
IsNumeric - Finds whether a variable is a number or a numeric string
func IsWritable ¶
IsWritable - Tells whether the filename is writable
func JsonDecode ¶
JsonDecode - Decodes a JSON string
func JsonEncode ¶
JsonEncode - Returns the JSON representation of a value
func Levenshtein ¶
Levenshtein levenshtein() costIns: Defines the cost of insertion. costRep: Defines the cost of replacement. costDel: Defines the cost of deletion.
func Log1p ¶
Log1p - Returns log(1 + number) computed in a way that is accurate even when the value of number is close to zero
func MapMergeKeyInterface ¶ added in v1.0.3
func MapMergeKeyInterface(arr1, arr2 map[interface{}]interface{}) map[interface{}]interface{}
func MapMergeString ¶ added in v1.0.3
func MemoryGetUsage ¶
MemoryGetUsage memory_get_usage() return in bytes
func NumberFormat ¶
NumberFormat number_format() decimals: Sets the number of decimal points. decPoint: Sets the separator for the decimal point. thousandsSep: Sets the thousands separator.
func ParseURL ¶
ParseURL parse_url() Parse a URL and return its components -1: all; 1: scheme; 2: host; 4: port; 8: user; 16: pass; 32: path; 64: query; 128: fragment
func Pathinfo ¶
Pathinfo pathinfo() -1: all; 1: dirname; 2: basename; 4: extension; 8: filename Usage: Pathinfo("/home/go/path/src/php2go/php2go.go", 1|2|4|8)
func PrintR ¶
func PrintR(v interface{})
PrintR - Prints human-readable information about a variable
func Rawurldecode ¶
Rawurldecode - Decodes URL-encoded string
func Rawurlencode ¶
Rawurlencode - URL-encode according to RFC 3986
func SimilarText ¶
SimilarText similar_text()
func StrReplace ¶
StrReplace str_replace()
func StrToTimeDateTime ¶ added in v1.0.3
func StrToTimeDateTime(strtime interface{}) int64
例如:2019-01-31 00:00:00
func Strtotime ¶
Strtotime strtotime() Strtotime("02/01/2006 15:04:05", "02/01/2016 15:04:05") == 1451747045 Strtotime("3 04 PM", "8 41 PM") == -62167144740
func Strtr ¶
Strtr strtr()
If the parameter length is 1, type is: map[string]string Strtr("baab", map[string]string{"ab": "01"}) will return "ba01" If the parameter length is 2, type is: string, string Strtr("baab", "ab", "01") will return "1001", a => 0; b => 1.
func SubstrCompare ¶ added in v1.0.3
二进制安全比较字符串
func SubstrCount ¶
SubstrCount - Count the number of substring occurrences
func SysGetTempDir ¶
func SysGetTempDir() string
SysGetTempDir - Returns directory path used for temporary files
func System ¶
System system() returnVar, 0: succ; 1: fail Returns the last line of the command output on success, and "" on failure.
func Ternary ¶
func Ternary(condition bool, trueVal, falseVal interface{}) interface{}
Ternary Ternary expression max := Ternary(a > b, a, b).(int)
func VersionCompare ¶
VersionCompare version_compare() The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively. special version strings these are handled in the following order, (any string not found) < dev < alpha = a < beta = b < RC = rc < # < pl = p Usage: VersionCompare("1.2.3-alpha", "1.2.3RC7", '>=') VersionCompare("1.2.3-beta", "1.2.3pl", 'lt') VersionCompare("1.1_dev", "1.2any", 'eq')
Types ¶
This section is empty.
Source Files ¶
- addcslashes.go
- addslashes.go
- array.go
- array_change_key_case.go
- array_chunk.go
- array_column.go
- array_count_values.go
- array_diff.go
- array_fill.go
- array_fill_keys.go
- array_flip.go
- array_intersect.go
- array_key_exists.go
- array_key_first.go
- array_key_last.go
- array_keys.go
- array_merge.go
- array_push.go
- array_reverse.go
- array_search.go
- base64.go
- basename.go
- checkdate.go
- chunk_split.go
- date.go
- date_add.go
- datetime.go
- directory.go
- doc.go
- echo.go
- exec.go
- exit.go
- file_exists.go
- file_get_contents.go
- file_put_contents.go
- filesystem.go
- get_env.go
- helpers.go
- helpers_unix.go
- html_entity_decode.go
- htmlentities.go
- init.go
- ip_info.go
- is_file.go
- is_numeric.go
- json.go
- math.go
- md5.go
- number_format.go
- print.go
- print_r.go
- scandir.go
- sha1.go
- sleep.go
- strings.go
- stringval.go
- strtotime.go
- substr_compare.go
- sys_get_temp_dir.go
- time.go
- url.go
- variable.go