Instance methods
array(*ele)
Create an array
php.array("") # =>
Sourcearray_key_exists(key, arr)
Checks if the given key or index exists in the array
php.array_key_exists(key, arr) # =>
Sourcebase64_decode(str)
Decodes data encoded with MIME base64
php.base64_decode("VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==") # => This is an encoded string
Sourcebase64_encode(str)
Encodes data with MIME base64
php.base64_encode("This is an encoded string") # => VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
Sourcebasename(path)
Returns trailing name component of path
php.basename("/foo/bar/file.cr") # => # => "file.cr"
Sourcecall_user_func
Call the callback given by the first parameter
php.() # =>
Sourcechdir(directory)
Change directory
php.chdir(directory) # =>
Sourceclass_exists(class_name)
Checks if the class has been defined
php.class_exists("some_class") # => bool
Sourcecount(array)
Count all elements in an array, or something in an object
php.count(some_array) # =>
Sourcedie(die)
Equivalent to exit
php.() # =>
Sourcedirname(filename)
Returns a parent directory's path
see https://crystal-lang.org/api/0.33.0/File.html#dirname(path):String-class-method
php.() # =>
Sourceecho(string)
Output one or more strings
php.() # =>
Sourceempty(obj)
Determine whether a variable is empty
php.() # =>
Sourceexplode(expl, strexp)
Split a string by a string
php.explode(" ", "piece1 piece2 piece3 piece4 piece5 piece6")
Sourcefclose(handle)
Closes an open file pointer
php.() # =>
Sourcefgets(handle)
Gets line from file pointer
php.() # =>
Sourcefile_exists(filename)
Checks whether a file or directory exists
php.file_exists("/path/to/foo.txt") # =>
Sourcefile_get_contents(filename)
Reads entire file into a string
php.() # =>
Sourcefile_put_contents(filename, context)
Write data to a file
php.file_put_contents("people.txt", "John Smith\n") # =>
Sourcefopen(filename, mode)
Opens file or URL
php.fopen("c:\\folder\\resource.txt", "r")
Sourcefread(handle, encoding = nil)
Binary-safe file read
php.() # =>
Sourcefwrite(filename, content)
Binary-safe file write
php.() # =>
Sourcegettext(message)
Lookup a message in the current domain
php.() # =>
Sourcegzcompress(data, level = 3)
Compress a string
php.() # =>
Sourcegzuncompress(data, length = 0)
Uncompress a compressed string
php.() # =>
Sourcehtml_entity_decode(string)
Convert HTML entities to their corresponding characters
php.() # =>
Sourcehtmlspecialchars(string)
Convert special characters to HTML entities
php.htmlspecialchars("<a href='test'>Test</a>") # =>
Sourcehttp_build_query(obj)
Generate URL-encoded query string
php.() # =>
Sourceip2long(ip_address)
Converts a string containing an (IPv4) Internet Protocol dotted address into a long integer
php.() # =>
Sourceis_a(obj, classname)
Checks if the object is of this class or has this class as one of its parents
php.() # =>
Sourceis_dir(dirpath)
ells whether the filename is a directory
php.() # =>
Sourceis_file(filepath)
Tells whether the filename is a regular file
php.() # =>
Sourceis_numeric(number)
Finds whether a variable is a number or a numeric string
php.() # =>
Sourceisset(var)
Determine if a variable is declared and is different than NULL
php.() # =>
Sourcejson_decode(data, as_array = false)
Decodes a JSON string
php.() # =>
Sourcejson_encode(obj)
Returns the JSON representation of a value
php.() # =>
Sourceksort(hash)
Sort an array by key
php.() # =>
Sourcelong2ip(long)
Converts an long integer address into a string in (IPv4) Internet standard dotted format
php.() # =>
Sourcemd5(string)
Calculate the md5 hash of a string
php.md5("apple") # => 1f3870be274f6c49b3e31a0c6728957f
Sourcemethod_exists(obj, method_name)
Checks if the class method exists
php.method_exists("Directory", "read") # => false
Sourcemicrotime(get_as_float = false)
Return current Unix timestamp with microseconds
php.() # =>
Sourcemkdir(path, mode = 511)
Makes directory
php.mkdir("/to/mode", 755) # =>
Sourcemktime(hour = nil, min = nil, sec = nil, date = nil, month = nil, year = nil, is_dst = -1)
Get Unix timestamp for a date
php.() # =>
Sourcemove_uploaded_file(tmp_path, new_path)
Moves an uploaded file to a new location
php.() # =>
Sourcenl2br(string)
Inserts HTML line breaks before all newlines in a string
php.nl2br("foo isn't\n bar") # => foo isn't<br /> bar
Sourceopendir(dirpath)
Open directory handle
php.("/etc/php5/")
Sourceparse_str(str, hash)
Parses the string into variables
php.() # =>
Sourcepassthru(cmd)
Execute an external program and display raw output
php.() # =>
Sourcepathinfo(filepath)
Returns information about a file path
php.pathinfo("/www/htdocs/inc/lib.inc") # =>
Sourceprint_r(argument, ret = false, count = 1)
Prints human-readable information about a variable
php.() # =>
Sourcereaddir(dir_handle)
Read entry from directory handle
php.() # =>
Sourcerealpath(path)
Returns canonicalized absolute pathname
php.() # =>
Sourceserialize(argument)
Generates a storable representation of a value
php.() # =>
Sourcesession_start
Start new or resume existing session
php.() # =>
Sourcesetcookie(cname, cvalue, expire = nil, domain = nil)
Send a cookie
php.() # =>
Sourcestrpos(haystack, needle)
Find the position of the first occurrence of a substring in a string
php.() # =>
Sourcestrtolower(str)
Make a string lowercase
php.() # =>
Sourcestrtotime(date_string, cur = nil)
Parse about any English textual datetime description into a Unix timestamp
php.strtotime("now") # => 1587855648
Sourcestrtoupper(str)
Make a string uppercase
php.strtoupper("Mary Had A Little Lamb and She LOVED It So") # => Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
Sourcestrtr(str, replace_pairs)
Translate characters or replace substrings
php.() # =>
Sourcesubstr(string, from, to = nil)
Return part of a string
php.substr("abcdef", -1) # => returns "f"
php.substr("abcdef", -2) # => returns "ef"
Sourcetime
Return current Unix timestamp
php.time => 1587855792
Sourcetrim(argument)
Strip whitespace (or other characters) from the beginning and end of a string
php.() # =>
Sourceucwords(string)
Uppercase the first character of each word in a string
php.ucwords("hello world!") # => "Hello World!"
Sourceunlink(filepath)
Deletes a file
php.unlink("test.html")
Sourceunserialize(argument)
Creates a PHP value from a stored representation
php.() # =>
Sourceurldecode(string)
Decodes URL-encoded string
php.urldecode("peter+%2B+paul") # => "peter+++paul"
Sourceurlencode(string)
URL-encodes string
php.urlencode("hello world!") # => "hello%20world!"
Sourceutf8_decode(string)
Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1
php.utf8_decode(string) # =>
Sourceutf8_encode(string)
Encodes an ISO-8859-1 string to UTF-8
php.utf8_encode(string) # =>
Source