php

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

*此包内主要是php中关联数组相关的操作
*本包内的数组均指map[string]interface{}

*此包内主要是php中索引数组相关的操作
*本包内的数组均指[]interface{}

* 此包內是关于时间和日期的相关函数

this file contains some functions that not available in Go

字符串操作相关函数

这个包是关于数据类型转换的

Index

Constants

View Source
const TYPE_VALUE_SEPARATOR = ':'
View Source
const VALUES_SEPARATOR = ';'

Variables

View Source
var (
	// ErrMalformedRegexp is returned when provided regexp string too short
	ErrMalformedRegexp = errors.New("Malformed Regexp")
	// ErrCantFindClosingSeparator is returned when provided regexp string
	// has wrong open/close separator configuration
	ErrCantFindClosingSeparator = errors.New("Cant find closing separator")
)

Functions

func Abs

func Abs(n float64) float64

func Acos

func Acos(val complex128) complex128

func Acosh

func Acosh(val complex128) complex128

func Addslashes

func Addslashes(str string) string

============================================================================================

func ArraySearchInt

func ArraySearchInt(arr []int, needle int) int

============================================================================================

func ArraySearchInt64

func ArraySearchInt64(arr []int64, needle int64) int

============================================================================================

func ArraySearchString

func ArraySearchString(arr []string, needle string) int

============================================================================================

func Array_diff

func Array_diff(m ...interface{}) interface{}

* 计算数组的差集 在第一个ArrayMap中但不在剩余ArrayMap中的元素

func Array_diff_assoc

func Array_diff_assoc(m ...interface{}) interface{}

func Array_key_exists

func Array_key_exists(key interface{}, array interface{}) bool

func Array_keys

func Array_keys(array interface{}) []interface{}

func Array_merge

func Array_merge(m ...interface{}) interface{}

func Array_values

func Array_values(array interface{}) []interface{}

func Asin

func Asin(val complex128) complex128

func Asinh

func Asinh(val complex128) complex128

func Atan

func Atan(val complex128) complex128

func Atanh

func Atanh(val complex128) complex128

func Base64_decode

func Base64_decode(str string) string

func Base64_encode

func Base64_encode(str string) string

func Base_convert

func Base_convert(num string, frombase, tobase int) (string, error)

func Basename

func Basename(file_path string) string

func Bin2hex

func Bin2hex(str string) string

func Bindec

func Bindec(bin string) (int64, error)

func Boolval

func Boolval(val interface{}) bool

func Ceil

func Ceil(f float64) float64

func Chdir

func Chdir(dir string) error

func Checkdate

func Checkdate(month, day, year int) bool

func Chgrp

func Chgrp(filename string, group interface{}) error

func Chmod

func Chmod(filename string, mode int) error

func Chown

func Chown(filename string, user interface{}) error

func Chr

func Chr(ascii int) string

func Chroot

func Chroot(dir string) error

func Chunk_split

func Chunk_split(str string, chunkLen int, end string) string

============================================================================================

func ClearError

func ClearError()

============================================================================================

func Compile

func Compile(str string) (*regexp.Regexp, error)

Compile parses a regular expression in PHP format and returns, if successful, a Regexp object that can be used to match against text.

func Date

func Date(format string, timestamp int64) string

============================================================================================

func Dirname

func Dirname(path string) string

============================================================================================

func Empty

func Empty(args ...interface{}) bool

func Error

func Error(separator string) string

============================================================================================

func Explode

func Explode(sep, s string) []string

func File_exists

func File_exists(filename string) bool

func File_get_contents

func File_get_contents(url string) string

func File_put_contents

func File_put_contents(fileName string, write_data string) int

func Filemtime

func Filemtime(filename string) int64

============================================================================================

func Filesize

func Filesize(filename string) int64

============================================================================================

func Filetype

func Filetype(filename string) string

============================================================================================

func FloatPrecision

func FloatPrecision(num float64, precision int) float64

func Fread

func Fread(fp *net.Conn, count int) string

func Fsockopen

func Fsockopen(hostname string, port int, errno *int, errstr *string, timeout int64) *net.Conn

func Fwrite

func Fwrite(fp *net.Conn, data string) int

func Gethostbyname

func Gethostbyname(hostname string) string

func Hex2bin

func Hex2bin(str string) (ret string)

func Htmlspecialchars

func Htmlspecialchars(s string) string

func Htmlspecialchars_decode

func Htmlspecialchars_decode(s string) string

func Htmlwrap

func Htmlwrap(str string, width int, breakStr string, cut bool) string

============================================================================================

func Implode

func Implode(sep string, strarr []string) string

func InArrayFloat64

func InArrayFloat64(arr []float64, needle float64) bool

============================================================================================

func InArrayInt

func InArrayInt(arr []int, needle int) bool

============================================================================================

func InArrayInt64

func InArrayInt64(arr []int64, needle int64) bool

============================================================================================

func InArrayString

func InArrayString(arr []string, needle string) bool

============================================================================================

func In_array

func In_array(single interface{}, array interface{}) bool

support: string, (u)int8 (u)int16 (u)int (u)int32 (u)int64

func Int64join

func Int64join(a []int64, sep string) string

============================================================================================

func Int64split

func Int64split(s, sep string) []int64

============================================================================================

func Intjoin

func Intjoin(a []int, sep string) string

============================================================================================

func Intsplit

func Intsplit(s, sep string) []int

============================================================================================

func Intval

func Intval(val interface{}) int

func IsDir

func IsDir(path string) bool

func IsFile

func IsFile(path string) bool

func IsNumeric

func IsNumeric(x interface{}) bool

func Is_array

func Is_array(value interface{}) int

return 1 is array, 2 is map

func Is_dir

func Is_dir(filepath string) bool

func Is_file

func Is_file(filename string) bool

============================================================================================

func Is_numeric

func Is_numeric(data interface{}) bool

func Isset

func Isset(args ...interface{}) bool

func Join

func Join(arg string, array []string) string

============================================================================================

func Ltrim

func Ltrim(s1, s2 string) string

func Max

func Max(x, y float64) float64

func Md5

func Md5(str string) string

func Md5_file

func Md5_file(filepath string) (string, error)

func Microtime

func Microtime() int64

func Min

func Min(x, y float64) float64

func Mkdir

func Mkdir(filepath string, mode uint32) bool

func Mt_rand

func Mt_rand(m ...int) int

func MustCompile

func MustCompile(str string) *regexp.Regexp

MustCompile is like Compile but panics if the expression cannot be parsed. It simplifies safe initialization of global variables holding compiled regular expressions.

func Nl2br

func Nl2br(str string, args ...bool) string

func Ord

func Ord(str string) int

func Parse_str

func Parse_str(s string) map[string][]string

============================================================================================

func Parse_str_s

func Parse_str_s(s string) map[string]string

func Parse_url

func Parse_url(strurl string) (map[string]string, bool)

func Pfsockopen

func Pfsockopen(hostname string, port int, errno *int, errstr *string, timeout int64) *net.Conn

func Pow

func Pow(x, y float64) float64

func Preg_match

func Preg_match(pattern, subject string) bool

func Preg_match_r

func Preg_match_r(pattern, subject string) ([]string, bool)

func Preg_quote

func Preg_quote(str, delimiter string) string

func Preg_replace

func Preg_replace(pattern, replacement interface{}, str string) string

func QuotedPrintableDecode

func QuotedPrintableDecode(data string) string

============================================================================================

func Quotemeta

func Quotemeta(str string) string

============================================================================================

func Rand

func Rand(m ...int) int

============================================================================================

func Range

func Range(start int, end int, args ...int) []int

func Rawurldecode

func Rawurldecode(str string) string

============================================================================================

func Rawurlencode

func Rawurlencode(str string) string

func Realpath

func Realpath(path string) string

func Rename

func Rename(oldName string, newName string) bool

============================================================================================

func Rmdir

func Rmdir(dirname string, args ...bool) bool

============================================================================================

func Round

func Round(num float64) int

func Rtrim

func Rtrim(s1, s2 string) string

func Serialize

func Serialize(value interface{}) (result string)
func Serialize(value interface{}) (result string, err error) {
	buf := new(bytes.Buffer)
	err = encodeValue(buf, value)
	if err == nil {
		result = buf.String()
	}
	return
}

func Sha1

func Sha1(data string) string
============================================================================================
func Base64Encode(data string) string {
    var buf bytes.Buffer
    encoder := base64.NewEncoder(base64.StdEncoding, &buf)
    encoder.Write([]byte(data))
    encoder.Close()
    return buf.String()
}

/* ============================================================================================ */

func Base64Decode(data string) string {
   data = strings.Replace(data, "\r", "", -1)
   data = strings.Replace(data, "\n", "", -1)
   var buf = bytes.NewBufferString(data)
   var res bytes.Buffer
   decoder := base64.NewDecoder(base64.StdEncoding, buf)
   res.ReadFrom(decoder)
   return res.String()
}

/* ============================================================================================ */

func Md5(data string) string {
    var h = md5.New()
    h.Write([]byte(data))
    return fmt.Sprintf("%x", h.Sum(nil))
}
============================================================================================

func ShowError

func ShowError()

============================================================================================

func Sleep

func Sleep(s int)

func Sprintf

func Sprintf(format string, a ...interface{}) string

func Str_pad

func Str_pad(str string, padLength int, padStr string, padType int) string

============================================================================================

func Str_repeat

func Str_repeat(str string, num int) string

============================================================================================

func Str_replace

func Str_replace(from, to interface{}, str string, count ...int) string

func Strcasecmp

func Strcasecmp(str1, str2 string) bool

func Strchr

func Strchr(haystack string, needle string) string

============================================================================================

func Strcspn

func Strcspn(str1 string, str2 string) int

============================================================================================

func Strip_tags

func Strip_tags(s string) string

============================================================================================

func Stripslashes

func Stripslashes(str string) string

============================================================================================

func Stristr

func Stristr(haystack string, needle string) string

============================================================================================

func Strlen

func Strlen(str string) int

func Strpos

func Strpos(str string, sep string) int

func Strrchr

func Strrchr(haystack string, needle string) string

============================================================================================

func Strrev

func Strrev(str string) string

============================================================================================

func Strrpos

func Strrpos(haystack string, needle string) int

============================================================================================

func Strspn

func Strspn(str1 string, str2 string) int

============================================================================================

func Strstr

func Strstr(haystack string, needle string) string

============================================================================================

func Strtolower

func Strtolower(str string) string

func Strtotime

func Strtotime(strTime string, args ...string) int64

============================================================================================

func Strtoupper

func Strtoupper(str string) string

func Strtr

func Strtr(str string, from string, to string) string

============================================================================================

func Strval

func Strval(val interface{}) string

func Substr

func Substr(str string, args ...int) string

func Substr_count

func Substr_count(haystack string, needle string) int

============================================================================================

func Substr_replace

func Substr_replace(str string, replacement string, start int, length int) string

============================================================================================

func Time

func Time() int64

func Trim

func Trim(s string) string

func Type

func Type(args ...interface{}) string

func Ucfirst

func Ucfirst(str string) string

============================================================================================

func Ucwords

func Ucwords(str string) string

============================================================================================

func Uniqid

func Uniqid(str string) string
func Unlink(filename string) bool

============================================================================================

func Unserialize

func Unserialize(value string) (result interface{})
func Unserialize(value string) (result interface{}, err error) {
	decoder := &PhpDecoder{
		source: strings.NewReader(value),
	}
	result, err = decoder.DecodeValue()
	return
}

func Urldecode

func Urldecode(str string) string

============================================================================================

func Urlencode

func Urlencode(str string) string

rawurlencode遵守是94年国际标准备忘录RFC 1738, urlencode实现的是传统做法,和上者的主要区别是对空格的转义是'+'而不是'%20' javascript的encodeURL也是94年标准, 而javascript的escape是另一种用"%xxx"标记unicode编码的方法。 推荐在PHP中使用用rawurlencode。弃用urlencode

============================================================================================

func Wordwrap

func Wordwrap(str string, width int, breakStr string, cut bool) string

============================================================================================

Types

type ArrayMap

type ArrayMap map[string]interface{}

func Array_change_key_case

func Array_change_key_case(arr ArrayMap, cs Case) ArrayMap

type ArraySlice

type ArraySlice []interface{}

func Array_chunk

func Array_chunk(input ArraySlice, size int) ArraySlice

type Case

type Case int
const (
	CASE_UPPER Case = 1
	CASE_LOWER Case = 0
)

type PhpDecoder

type PhpDecoder struct {
	// contains filtered or unexported fields
}

func (*PhpDecoder) DecodeValue

func (decoder *PhpDecoder) DecodeValue() (value interface{}, err error)

all integer is int64,float number is float64

type PhpObject

type PhpObject struct {
	// contains filtered or unexported fields
}

func NewPhpObject

func NewPhpObject() *PhpObject

func (*PhpObject) GetClassName

func (obj *PhpObject) GetClassName() string

func (*PhpObject) GetMembers

func (obj *PhpObject) GetMembers() map[string]interface{}

func (*PhpObject) GetPrivateMemberValue

func (obj *PhpObject) GetPrivateMemberValue(memberName string) (interface{}, bool)

func (*PhpObject) GetProtectedMemberValue

func (obj *PhpObject) GetProtectedMemberValue(memberName string) (interface{}, bool)

func (*PhpObject) GetPublicMemberValue

func (obj *PhpObject) GetPublicMemberValue(memberName string) (interface{}, bool)

func (*PhpObject) SetClassName

func (obj *PhpObject) SetClassName(cName string)

func (*PhpObject) SetPrivateMemberValue

func (obj *PhpObject) SetPrivateMemberValue(memberName string, value interface{})

func (*PhpObject) SetProtectedMemberValue

func (obj *PhpObject) SetProtectedMemberValue(memberName string, value interface{})

func (*PhpObject) SetPublicMemberValue

func (obj *PhpObject) SetPublicMemberValue(memberName string, value interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL