Skip to content

Wiki Constant

Danijel Galić edited this page Jan 23, 2024 · 1 revision
final class \FireHub\Core\Support\LowLevel\Constant()

Important

This class is marked as final.

### Constant low-level class proxy class

Class allows you to obtain information about constants.

This class was created by Danijel Galić <danijel.galic@outlook.com>
Copyright: 2024 FireHub Web Application Framework
License: <https://opensource.org/licenses/OSL-3.0> OSL Open Source License version 3
Version: GIT: $Id$ Blob checksum.

Fully Qualified Class Name:  \FireHub\Core\Support\LowLevel\Constant
Source code:  view source code
Blame:  view blame
History:  view history

Methods

Type Name Title
public static define ### Defines a named constant
public static defined ### Checks whether a given named constant exists
public static value ### Returns the value of a constant
public static Constant::define(string $name, null|array|bool|float|int|string $value):true

### Defines a named constant

Defines a named constant at runtime.

Source code:  view source code
Blame:  view blame

Parameters

  • string $name - non-empty-string The name of the constant.
  • null or array or bool or float or int or string $value - null|array<array-key, mixed>|scalar The value of the constant.

Returns

  • true - True on success.
public static Constant::defined(string $name):bool

Note

This function works also with class constants and enum cases.

### Checks whether a given named constant exists

This function works also with class constants and enum cases.

Source code:  view source code
Blame:  view blame

Parameters

  • string $name - non-empty-string The constant name.

Returns

  • bool - True if the named constant given by name parameter has been defined, false otherwise.
public static Constant::value(string $name):mixed

Note

This function works also with class constants and enum cases.

### Returns the value of a constant

Method Constant#value() is useful if you need to retrieve the value of a constant, but do not know its name. I.e., it is stored in a variable or returned by a function.

Source code:  view source code
Blame:  view blame

Parameters

  • string $name - non-empty-string The constant name.

Throws

  • \Error - If the constant is not defined.

Returns

  • mixed - The value of the constant.
Clone this wiki locally