php
PHP interop: method calls, object creation, and PHP array access.
Functions
14 functions
No functions match
Jump to function (14) ›
php/->
(php/-> object call*)
(php/:: class call*)
Access to an object property or result of chained calls.
Deprecated: write (.format date "Y-m-d") for a method and (.-prop obj) for a property. Chains thread with plain ->.
Example:
(.format date "Y-m-d")
php/::
(php/:: class (method-name expr*))
(php/:: class call*)
Calls a static method or property from a PHP class. Both method-name and property must be symbols and cannot be an evaluated value.
Deprecated: write (DateTime/createFromFormat "Y-m-d" "2024-01-01") for a method and DateTime/ATOM for a constant.
Example:
(DateTime/createFromFormat "Y-m-d" "2024-01-01")
php/aget
(php/aget arr index)
Equivalent to PHP's arr[index] ?? null.
Example:
(php/aget (php/array "a" "b" "c") 1) ; => "b"
php/aget-in
(php/aget-in arr ks)
Equivalent to PHP's arr[k1][k2][k...] ?? null.
Example:
(php/aget-in nested-arr ["users" 0 "name"])
php/apush
(php/apush arr value)
Equivalent to PHP's arr[] = value.
Example:
(php/apush arr "new-item")
php/apush-in
(php/apush-in arr ks value)
Equivalent to PHP's arr[k1][k2][k...][] = value.
Example:
(php/apush-in arr ["users"] {:name "Bob"})
php/aset
(php/aset arr index value)
Equivalent to PHP's arr[index] = value.
Example:
(php/aset arr 0 "new-value")
php/aset-in
(php/aset-in arr ks value)
Equivalent to PHP's arr[k1][k2][k...] = value.
Example:
(php/aset-in arr ["users" 0 "name"] "Alice")
php/aunset
(php/aunset arr index)
Equivalent to PHP's unset(arr[index]).
Example:
(php/aunset arr "key-to-remove")
php/aunset-in
(php/aunset-in arr ks)
Equivalent to PHP's unset(arr[k1][k2][k...]).
Example:
(php/aunset-in arr ["users" 0])
php/callable
(php/callable \function)
(php/callable Class method)
(php/callable object method)
Builds a native PHP 8.1 first-class callable (...) from a free function, a static method, or an instance method, without allocating an fn wrapper.
Example:
(map (php/callable \strtoupper) ["a" "b"])
php/new
(php/new expr args*)
Evaluates expr and creates a new PHP class using the arguments. The instance of the class is returned.
Deprecated: write (new DateTime "2024-01-01") or (DateTime. "2024-01-01").
Example:
(new DateTime "2024-01-01")
php/oset
(php/oset (.-property object) value)
(php/oset (php/:: class property) value)
Sets a class/object property. set! is the top-level name for the same thing.
Example:
(php/oset (.-name obj) "Alice")
php/ref
(.method object (php/ref local))
Marks a local variable as passed by reference in an interop call, so an output-parameter PHP method can write back into the Phel binding.
Example:
(.bindColumn stmt 1 (php/ref out))