class

Phpcr::Php

Inherits Reference < Object

Constructors

Instance methods

array(*ele)

Create an array

php.array("") # =>
Source
array_key_exists(key, arr)

Checks if the given key or index exists in the array

php.array_key_exists(key, arr) # =>
Source
base64_decode(str)

Decodes data encoded with MIME base64

php.base64_decode("VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==") # => This is an encoded string
Source
base64_encode(str)

Encodes data with MIME base64

php.base64_encode("This is an encoded string") # => VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
Source
basename(path)

Returns trailing name component of path

php.basename("/foo/bar/file.cr") # => # => "file.cr"
Source
call_user_func

Call the callback given by the first parameter

php.() # =>
Source
chdir(directory)

Change directory

php.chdir(directory) # =>
Source
class_exists(class_name)

Checks if the class has been defined

php.class_exists("some_class") # => bool
Source
count(array)

Count all elements in an array, or something in an object

php.count(some_array) # =>
Source
date(date_format, date_input = nil)

Format a local time/date

php.() # =>
Source
die(die)

Equivalent to exit

php.() # =>
Source
dirname(filename)

Returns a parent directory's path see https://crystal-lang.org/api/0.33.0/File.html#dirname(path):String-class-method

php.() # =>
Source
echo(string)

Output one or more strings

php.() # =>
Source
empty(obj)

Determine whether a variable is empty

php.() # =>
Source
explode(expl, strexp)

Split a string by a string

php.explode(" ", "piece1 piece2 piece3 piece4 piece5 piece6")
Source
fclose(handle)

Closes an open file pointer

php.() # =>
Source
fgets(handle)

Gets line from file pointer

php.() # =>
Source
file_exists(filename)

Checks whether a file or directory exists

php.file_exists("/path/to/foo.txt") # =>
Source
file_get_contents(filename)

Reads entire file into a string

php.() # =>
Source
file_put_contents(filename, context)

Write data to a file

php.file_put_contents("people.txt", "John Smith\n") # =>
Source
fopen(filename, mode)

Opens file or URL

php.fopen("c:\\folder\\resource.txt", "r")
Source
fread(handle, encoding = nil)

Binary-safe file read

php.() # =>
Source
fwrite(filename, content)

Binary-safe file write

php.() # =>
Source
gettext(message)

Lookup a message in the current domain

php.() # =>
Source
gzcompress(data, level = 3)

Compress a string

php.() # =>
Source
gzuncompress(data, length = 0)

Uncompress a compressed string

php.() # =>
Source
header(header)

Send a raw HTTP header

php.() # =>
Source
html_entity_decode(string)

Convert HTML entities to their corresponding characters

php.() # =>
Source
htmlspecialchars(string)

Convert special characters to HTML entities

php.htmlspecialchars("<a href='test'>Test</a>") # =>
Source
http_build_query(obj)

Generate URL-encoded query string

php.() # =>
Source
include_once(filename)
php.() # =>
Source
ip2long(ip_address)

Converts a string containing an (IPv4) Internet Protocol dotted address into a long integer

php.() # =>
Source
is_a(obj, classname)

Checks if the object is of this class or has this class as one of its parents

php.() # =>
Source
is_dir(dirpath)

ells whether the filename is a directory

php.() # =>
Source
is_file(filepath)

Tells whether the filename is a regular file

php.() # =>
Source
is_numeric(number)

Finds whether a variable is a number or a numeric string

php.() # =>
Source
isset(var)

Determine if a variable is declared and is different than NULL

php.() # =>
Source
json_decode(data, as_array = false)

Decodes a JSON string

php.() # =>
Source
json_encode(obj)

Returns the JSON representation of a value

php.() # =>
Source
ksort(hash)

Sort an array by key

php.() # =>
Source
long2ip(long)

Converts an long integer address into a string in (IPv4) Internet standard dotted format

php.() # =>
Source
md5(string)

Calculate the md5 hash of a string

php.md5("apple") # => 1f3870be274f6c49b3e31a0c6728957f
Source
method_exists(obj, method_name)

Checks if the class method exists

php.method_exists("Directory", "read") # => false
Source
microtime(get_as_float = false)

Return current Unix timestamp with microseconds

php.() # =>
Source
mkdir(path, mode = 511)

Makes directory

php.mkdir("/to/mode", 755) # =>
Source
mktime(hour = nil, min = nil, sec = nil, date = nil, month = nil, year = nil, is_dst = -1)

Get Unix timestamp for a date

php.() # =>
Source
move_uploaded_file(tmp_path, new_path)

Moves an uploaded file to a new location

php.() # =>
Source
nl2br(string)

Inserts HTML line breaks before all newlines in a string

php.nl2br("foo isn't\n bar") # => foo isn't<br />  bar
Source
number_format(number, seperator = ".", delimiter = ",")

Format a number with grouped thousands

php.number_format(1234.56) # => 1,235
Source
opendir(dirpath)

Open directory handle

php.("/etc/php5/")
Source
parse_str(str, hash)

Parses the string into variables

php.() # =>
Source
passthru(cmd)

Execute an external program and display raw output

php.() # =>
Source
pathinfo(filepath)

Returns information about a file path

php.pathinfo("/www/htdocs/inc/lib.inc") # =>
Source
readdir(dir_handle)

Read entry from directory handle

php.() # =>
Source
realpath(path)

Returns canonicalized absolute pathname

php.() # =>
Source
require_once(filename)
php.() # =>
Source
serialize(argument)

Generates a storable representation of a value

php.() # =>
Source
session_start

Start new or resume existing session

php.() # =>
Source
setcookie(cname, cvalue, expire = nil, domain = nil)

Send a cookie

php.() # =>
Source
strip_tags(htmlstr)

Strip HTML and PHP tags from a string

php.strip_tags("<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>") # => Test paragraph. Other text
<p>Test paragraph.</p> <a href="#fragment">Other text</a>
Source
strpos(haystack, needle)

Find the position of the first occurrence of a substring in a string

php.() # =>
Source
strtolower(str)

Make a string lowercase

php.() # =>
Source
strtotime(date_string, cur = nil)

Parse about any English textual datetime description into a Unix timestamp

php.strtotime("now") # => 1587855648
Source
strtoupper(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
Source
strtr(str, replace_pairs)

Translate characters or replace substrings

php.() # =>
Source
substr(string, from, to = nil)

Return part of a string

php.substr("abcdef", -1) # => returns "f"
php.substr("abcdef", -2) # => returns "ef"
Source
time

Return current Unix timestamp

php.time  => 1587855792
Source
trim(argument)

Strip whitespace (or other characters) from the beginning and end of a string

php.() # =>
Source
ucwords(string)

Uppercase the first character of each word in a string

php.ucwords("hello world!") # => "Hello World!"
Source
unserialize(argument)

Creates a PHP value from a stored representation

php.() # =>
Source
urldecode(string)

Decodes URL-encoded string

php.urldecode("peter+%2B+paul") # => "peter+++paul"
Source
urlencode(string)

URL-encodes string

php.urlencode("hello world!") # => "hello%20world!"
Source
utf8_decode(string)

Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1

php.utf8_decode(string) # =>
Source
utf8_encode(string)

Encodes an ISO-8859-1 string to UTF-8

php.utf8_encode(string) # =>
Source