Helpers

Helpers

CodefyPHP contains several global helper functions. Some of them are used throughout the framework and are available for use at any point.

is_error

Check whether variable is an Error instance.

Written by Joshua
August 14, 2024

esc_html

Escapes html.

Written by Joshua
August 14, 2024

esc_html__

Escapes a translated string to make it safe for HTML output.

Written by Joshua
August 14, 2024

esc_textarea

Escapes for textarea.

Written by Joshua
August 14, 2024

esc_url

Escapes a url.

Written by Joshua
August 14, 2024

esc_attr

Escaping for html attributes.

Written by Joshua
August 14, 2024

esc_attr__

Escapes a translated string to make it safe for HTML attribute.

Written by Joshua
August 14, 2024

esc_js

Escaping for inline javascript.

Written by Joshua
August 14, 2024

purify_html

Makes content safe to print on screen. This function should only be used on output.

Written by Joshua
August 14, 2024

flatten_array

Converts a multi-dimensional array into a regular array.

Written by Joshua
August 14, 2024

trim__

Trims all whitespace.

Written by Joshua
August 14, 2024

strip_tags__

Properly strip all HTML tags including script and style (default).

Written by Joshua
August 14, 2024

t__

Translates a string.

Written by Joshua
August 14, 2024

trigger_error__

Wrapper function for the core PHP function: trigger_error.

Written by Joshua
August 14, 2024

add_trailing_slash

Will remove trailing forward and backslashes if it exists already before adding a trailing forward slash. This prevents double slashing a string or path.

Written by Joshua
August 14, 2024

remove_trailing_slash

Removes trailing forward slashes and backslashes if they exist.

Written by Joshua
August 14, 2024

concat_ws

Concatenation with separator.

Written by Joshua
August 14, 2024

is_null__

Checks if a variable is null. Works the same as PHP’s native is_null() function. If $var is not set, an Undefined variable notice will be...

Written by Joshua
August 14, 2024

is_true__

Checks if return is true.

Written by Joshua
August 14, 2024

is_false__

Checks if return is false.

Written by Joshua
August 14, 2024

truncate_string

Truncates a string to the given length. It will optionally preserve HTML tags if $isHtml is set to true.

Written by Joshua
August 14, 2024

compact_unique_array

Strips out all duplicate values and compact the array.

Written by Joshua
August 14, 2024

convert_array_to_object

Takes an array and turns it into an object.

Written by Joshua
August 14, 2024

php_like

SQL Like operator for PHP.

Written by Joshua
August 14, 2024

php_where

SQL Where operator for PHP.

Written by Joshua
August 14, 2024

sort_element_callback

Sorts a structured array by Name property.

Written by Joshua
August 14, 2024

mail

An alternative to using PHP's native mail function with other options for SMTP (default), Qmail, and Sendmail.

Written by Joshua
September 5, 2024