\PhalApi_Tool

Tool Class

Only provide common tool, currently support:

  • get IP address
  • generate random string

Summary

Methods
Properties
Constants
getClientIp()
createRandStr()
arrIndex()
createDir()
deleteDir()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getClientIp()

getClientIp() : string

Get IP address

Returns

string —

such as: 192.168.1.1, return empty string when fail

createRandStr()

createRandStr(integer  $len, string  $chars = null) : string

Generate random string

Parameters

integer $len

the length or random string

string $chars

random chars source

Returns

string

arrIndex()

arrIndex(array  $arr, string|integer  $key, string  $default = '') : mixed

Get the value in the array if exists, or return default value

Parameters

array $arr

array

string|integer $key

index in the array

string $default

default value

Returns

mixed

createDir()

createDir(string  $path) 

Create folder or file with path

Parameters

string $path

path to be created

Throws

\PhalApi_Exception_BadRequest

deleteDir()

deleteDir(string  $path) 

Delete folder

  • DO NOT delete any IMPORTANT folders!

Parameters

string $path

path to be deleted