BASE_URL
Base URL of the application
public
mixed
BASE_URL
= \MilkCore\Route::url()
Base URL of the application
public
mixed
BASE_URL
= \MilkCore\Route::url()
Version identifier in format AAmmXX (YearMonth + sequence)
public
mixed
NEW_VERSION
= '250609'
Directory of the storage
public
mixed
STORAGE_DIR
= realpath(MILK_DIR . '/' . \MilkCore\Config::get('storage_dir', 'storage'))
Directory of the theme
public
mixed
THEME_DIR
= realpath(MILK_DIR . '/' . \MilkCore\Config::get('theme_dir', 'theme'))
URL to the theme directory
public
mixed
THEME_URL
= \MilkCore\Route::url() . "/" . (\MilkCore\Config::get('theme_dir') ?? 'theme')
Sanitizes and returns a string value
_r(mixed $var) : string
This function is used to safely handle user input by escaping special characters. It's suitable for general string sanitization when the output context is plain text.
The variable to sanitize
The sanitized string, or empty string if input is not scalar
Returns sanitized and translated string
_rt(mixed $var) : string
This function first translates the string using the current language settings and then sanitizes it for safe output. It's ideal for user-facing text that needs to support multiple languages.
The string to translate and sanitize
The translated and sanitized string, or empty string if input is not scalar
Returns HTML-escaped string
_rh(mixed $var) : string
Use this function when you need to output content within HTML. It converts special characters to HTML entities to prevent XSS attacks.
The string to escape
The HTML-escaped string, or empty string if input is not scalar
Esegue un preg_replace per eliminare i caratteri speciali Aggiunge un carattere se il primo è un numero
_raz(mixed $var) : mixed
Outputs a sanitized string
_p(mixed $var) : void
This function is a convenience wrapper that sanitizes and immediately outputs
a string. It's equivalent to echo _r($var) but more concise.
The string to sanitize and output
Outputs a translated and sanitized string
_pt(mixed $var) : void
This function combines translation and sanitization for output. It's commonly used for user interface text that needs to be both translated and safe to display.
The string to translate and output
Outputs an HTML-escaped string
_ph(mixed $var) : void
Use this function when you need to output content directly within HTML.
It's a shortcut for echo _rh($var).
The string to escape and output
Outputs a value as a JavaScript literal
_pjs(mixed $var) : void
This function safely outputs values within JavaScript code blocks by using json_encode() to properly escape the content. It handles all JavaScript data types including strings, numbers, arrays, and objects.
The value to output as JavaScript
Sanitizes a string for use in HTML IDs, classes, or other identifiers
_paz(string $var) : string
This function removes all non-alphanumeric characters and ensures the result starts with a letter. It's useful for creating safe HTML identifiers from user input.
The string to sanitize
The sanitized string with only alphanumeric characters and underscores, starting with a letter
Sanitizes and returns a positive integer
_absint(mixed $var) : int
This function ensures the returned value is always a non-negative integer. It's particularly useful for sanitizing IDs, counts, and other numeric values that should never be negative.
The value to sanitize
The sanitized positive integer, or 0 if conversion fails
Retrieves a value from an object or array with fallback support
get_val(object|array<string|int, mixed> $class, string $property) : mixed
This helper function provides a consistent way to access values from different data structures, including objects with magic getters or custom get_value methods. It's particularly useful for working with model objects that might implement custom value retrieval logic.
The object or array to get the value from
The property name or array key to retrieve
The value of the property, or null if not found
Converts an object or array of data into a format suitable for MySQL
to_mysql_array(mixed $obj[, array<string|int, mixed> $default_data = [] ]) : array<string|int, mixed>
This function handles conversion of various data structures (objects, arrays, models) into a format that can be used with MySQL queries. It supports model objects with a to_mysql_array() method and falls back to default data when needed.
The data to convert (model object, stdClass, or array)
Default data to use as a base (typically $_REQUEST or $_POST)
The converted data ready for MySQL operations