|
| 1 | +# php2go |
| 2 | + |
| 3 | +[![MIT licensed][3]][4] |
| 4 | + |
| 5 | +[3]: https://img.shields.io/badge/license-MIT-blue.svg |
| 6 | +[4]: LICENSE |
| 7 | + |
| 8 | +#### Introduce |
| 9 | +In the process of PHP to Golang,realize functions that are used frequently in some PHP code, making it easier and faster for PHPer to transform into Gopher! |
| 10 | + |
| 11 | +#### README |
| 12 | +[README](https://github.com/lihao1988/php2go/blob/main/README.md) |
| 13 | +[README-en](https://github.com/lihao1988/php2go/blob/main/README.en.md) |
| 14 | + |
| 15 | +#### Install |
| 16 | +```shell |
| 17 | +// github |
| 18 | +go get github.com/lihao1988/php2go |
| 19 | + |
| 20 | +// gitee |
| 21 | +go get gitee.com/lihao1988/php2go |
| 22 | +``` |
| 23 | + |
| 24 | +## Requirements |
| 25 | +Go 1.15 or above. |
| 26 | + |
| 27 | +## PHP Function |
| 28 | +### Array(Slice/Map) Functions |
| 29 | +```php |
| 30 | +## import array |
| 31 | + |
| 32 | +In() [PHP:in_array(),Checks if a value exists in an array] |
| 33 | +Keys() [PHP:array_keys(),Return all the keys or a subset of the keys of an array] |
| 34 | +Values() [PHP:array_values(),Return all the values of an array] |
| 35 | +Merge() [PHP:array_merge(),Merge one or more arrays] |
| 36 | +Unique() [PHP:array_unique(),Removes duplicate values from an array] |
| 37 | +Column() [PHP:array_column(),Return the values from a single column in the input array] |
| 38 | +Diff() [PHP:array_diff(),Computes the difference of arrays] |
| 39 | +Intersect() [PHP:array_intersect(),Computes the intersection of arrays] |
| 40 | +``` |
| 41 | +### Crypto Functions |
| 42 | +```php |
| 43 | +## import crypto |
| 44 | + |
| 45 | +MD5() [PHP:md5(),Calculate the md5 hash of a string] |
| 46 | +Sha1() [PHP:sha1(),Calculate the sha1 hash of a string] |
| 47 | +Base64Encode() [PHP:base64_encode(),Encodes data with MIME base64] |
| 48 | +Base64Decode() [PHP:base64_decode(),Decodes data encoded with MIME base64] |
| 49 | +``` |
| 50 | +### Date/Time Functions |
| 51 | +```php |
| 52 | +## import datetime |
| 53 | + |
| 54 | +Time() [PHP:time(),Return current Unix timestamp] |
| 55 | +StrToTime() [PHP:strtotime(),Parse about any English textual datetime description into a Unix timestamp] |
| 56 | +Date() [PHP:date(),Format a Unix timestamp] |
| 57 | +CheckDate() [PHP:checkdate(),Validate a Gregorian date] |
| 58 | +Sleep() [PHP:sleep(),Delay execution] |
| 59 | +Usleep() [PHP:usleep(),Delay execution in microseconds] |
| 60 | +``` |
| 61 | +### Filesystem Functions |
| 62 | +```php |
| 63 | +## import file |
| 64 | + |
| 65 | +Basename() [PHP:basename(),Returns trailing name component of path] |
| 66 | +Dirname() [PHP:dirname(),Returns a parent directory's path] |
| 67 | +Filesize() [PHP:filesize(),Gets file size] |
| 68 | +PathInfo() [PHP:pathinfo(),Returns information about a file path] |
| 69 | +FileExists() [PHP:file_exists(),Checks whether a file or directory exists] |
| 70 | +IsDir() [PHP:is_dir(),Tells whether the filename is a directory] |
| 71 | +IsFile() [PHP:is_file(),Tells whether the filename is a regular file] |
| 72 | +FileGetContents() [PHP:file_get_contents(),Reads entire file into a string] |
| 73 | +FilePutContents() [PHP:file_put_contents(),Write data to a file] |
| 74 | +Chmod() [PHP:chmod(),Changes file mode] |
| 75 | +Chown() [PHP:chown(),Changes file owner] |
| 76 | +``` |
| 77 | +### Math Functions |
| 78 | +```php |
| 79 | +## import math |
| 80 | + |
| 81 | +Abs() [PHP:abs(),Absolute value] |
| 82 | +Round() [PHP:round(),Rounds a float] |
| 83 | +Floor() [PHP:floor(),Round fractions down] |
| 84 | +Ceil() [PHP:ceil(),Round fractions up] |
| 85 | +Max() [PHP:max(),Find highest value] |
| 86 | +Min() [PHP:min(),Find lowest value] |
| 87 | +DecBin() [PHP:decbin(),Decimal to binary] |
| 88 | +DecHex() [PHP:dechex(),Decimal to hexadecimal] |
| 89 | +``` |
| 90 | +### String Functions |
| 91 | +```php |
| 92 | +## import string |
| 93 | + |
| 94 | +StrLen() [PHP:strlen(),Get string length] |
| 95 | +MbStrLen() [PHP:mb_strlen(),Get string length by UTF-8] |
| 96 | +SubstrCount() [PHP:substr_count(),Count the number of substring occurrences] |
| 97 | +Substr() [PHP:substr(),Return part of a string] |
| 98 | +MbSubstr() [PHP:mb_substr(),Get part of string by UTF-8] |
| 99 | +StrPos() [PHP:strpos(),Find the position of the first occurrence of a substring in a string] |
| 100 | +StrRPos() [PHP:strrpos(),Find the position of the last occurrence of a substring in a string] |
| 101 | +StrSplit() [PHP:str_split(),Convert a string to an array] |
| 102 | +UCFirst() [PHP:ucfirst(),Make a string's first character uppercase] |
| 103 | +``` |
| 104 | +### URL Functions |
| 105 | +```php |
| 106 | +## import url |
| 107 | + |
| 108 | +ParseUrl() [PHP:parse_url(),Parse a URL and return its components] |
| 109 | +UrlEncode() [PHP:urlencode(),URL-encodes string] |
| 110 | +UrlDecode() [PHP:urldecode(),Decodes URL-encoded string] |
| 111 | +RawUrlEncode() [PHP:rawurlencode(),URL-encode according to RFC 3986] |
| 112 | +RawUrlDecode() [PHP:rawurldecode(),Decode URL-encoded strings] |
| 113 | +HttpBuildQuery() [PHP:http_build_query(),Generate URL-encoded query string] |
| 114 | +``` |
| 115 | + |
| 116 | +## LICENSE |
| 117 | +PHP2Go source code is licensed under the [MIT](https://github.com/lihao1988/php2go/blob/main/LICENSE) Licence. |
0 commit comments