vendor/cakephp/cakephp/src/Corefunctions.php

CakePHP(tm) : Rapid Development Framework (https://cakephp.org) Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)

Licensed under The MIT License For full copyright and license information, please see the LICENSE.txt Redistributions of files must retain the above copyright notice.

Constants

DS

DS = DIRECTORY_SEPARATOR

Define DS as short form of DIRECTORY_SEPARATOR.

Functions

h()

h(mixed  $text, boolean  $double = true, string|null  $charset = null) : mixed

Convenience method for htmlspecialchars.

Parameters

mixed $text

Text to wrap through htmlspecialchars. Also works with arrays, and objects. Arrays will be mapped and have all their elements escaped. Objects will be string cast if they implement a __toString method. Otherwise the class name will be used. Other scalar types will be returned unchanged.

boolean $double

Encode existing html entities.

string|null $charset

Character set to use when escaping. Defaults to config value in mb_internal_encoding() or 'UTF-8'.

Returns

mixed —

Wrapped text.

pluginSplit()

pluginSplit(string  $name, boolean  $dotAppend = false, string|null  $plugin = null) : array

Splits a dot syntax plugin name into its plugin and class name.

If $name does not have a dot, then index 0 will be null.

Commonly used like

list($plugin, $name) = pluginSplit($name);

Parameters

string $name

The name you want to plugin split.

boolean $dotAppend

Set to true if you want the plugin to have a '.' appended to it.

string|null $plugin

Optional default plugin to use if no plugin is found. Defaults to null.

Returns

array —

Array with 2 indexes. 0 => plugin name, 1 => class name.

namespaceSplit()

namespaceSplit(string  $class) : array

Split the namespace from the classname.

Commonly used like list($namespace, $className) = namespaceSplit($class);.

Parameters

string $class

The full class name, ie Cake\Core\App.

Returns

array —

Array with 2 indexes. 0 => namespace, 1 => classname.

pr()

pr(mixed  $var) : mixed

print_r() convenience function.

In terminals this will act similar to using print_r() directly, when not run on cli print_r() will also wrap

 tags around the output of given variable. Similar to debug().

This function returns the same variable that was passed.

Parameters

mixed $var

Variable to print out.

Returns

mixed —

the same $var that was passed to this function

pj()

pj(mixed  $var) : mixed

json pretty print convenience function.

In terminals this will act similar to using json_encode() with JSON_PRETTY_PRINT directly, when not run on cli will also wrap

 tags around the output of given variable. Similar to pr().

This function returns the same variable that was passed.

Parameters

mixed $var

Variable to print out.

Returns

mixed —

the same $var that was passed to this function

env()

env(string  $key, string|null  $default = null) : string|boolean|null

Gets an environment variable from available sources, and provides emulation for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on IIS, or SCRIPT_NAME in CGI mode). Also exposes some additional custom environment information.

Parameters

string $key

Environment variable name.

string|null $default

Specify a default value in case the environment variable is not defined.

Returns

string|boolean|null —

Environment variable setting.

triggerWarning()

triggerWarning(string  $message) : void

Triggers an E_USER_WARNING.

Parameters

string $message

The warning message.

deprecationWarning()

deprecationWarning(string  $message, integer  $stackFrame = 1) : void

Helper method for outputting deprecation warnings

Parameters

string $message

The message to output as a deprecation warning.

integer $stackFrame

The stack frame to include in the error. Defaults to 1 as that should point to application/plugin code.

getTypeName()

getTypeName(mixed  $var) : string

Returns the objects class or var type of it's not an object

Parameters

mixed $var

Variable to check

Returns

string —

Returns the class name or variable type