Page Contents

While most of your day-to-day work in CakePHP will be utilizing
core classes and methods, CakePHP features a number of global
convenience functions that may come in handy. Many of these
functions are for use with CakePHP classes (loading model or
component classes), but many others make working with arrays or
strings a little easier.

We’ll also cover some of the constants available in CakePHP
applications. Using these constants will help make upgrades more
smooth, but are also convenient ways to point to certain files or
directories in your CakePHP application.

This function handles localization in CakePHP applications. The
$string_id identifies the ID for a translation. Strings
used for translations are treated as format strings for
sprintf(). You can supply additional arguments to replace
placeholders in your string:

Allows you to override the current domain for a single plural message
lookup. It also allows you to specify a category. Returns correct plural
form of message identified by $singular and $plural for count $count from
domain $domain.

Note that the category must be specified with an I18n class constant, instead of
only the constant name. The values are:

Returns correct plural form of the message identified by $singular and
$plural for count $count. It also allows you to specify a context. Some
languages have more than one form for plural messages dependent on the
count.

The context is a unique identifier for the translations string that makes it
unique within the same domain.

Allows you to override the current domain and context for a single plural
message lookup. Returns correct plural form of message identified by
$singular and $plural for count $count from domain $domain. Some languages
have more than one form for plural messages dependent on the count.

The context is a unique identifier for the translation string that makes it
unique within the same domain.

Allows you to override the current domain for a single plural message
lookup. It also allows you to specify a category and a context.
Returns correct plural form of message identified by $singular and $plural
for count $count from domain $domain.

The context is a unique identifier for the translations string that makes it
unique within the same domain.

Note that the category must be specified with an I18n class constant, instead of
only the constant name. The values are:

If the application’s DEBUG level is non-zero, $var is printed out.
If $showHTML is true or left as null, the data is rendered to be
browser-friendly.
If $showFrom is not set to false, the debug output will start with the line from
which it was called.
Also see Debugging

stackTrace(array $options = array())

If the application’s DEBUG level is non-zero, the stack trace is printed out.

Gets an environment variable from available sources. Used as a
backup if $_SERVER or $_ENV are disabled.

This function also emulates PHP_SELF and DOCUMENT_ROOT on
unsupporting servers. In fact, it’s a good idea to always use
env() instead of $_SERVER or getenv() (especially if
you plan to distribute the code), since it’s a full emulation
wrapper.