Search Results

  1. Return the value of the constant indicated by name. constant () 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. This function works also with class constants and enum cases.

    • Sleep

      Delay execution Delays the program execution for the given...

    • Uniqid

      Caution This function does not generate cryptographically...

    • Exit

      Notes ¶ Warning Prior to PHP 8.4.0, exit () was a language...

    • Usleep

      Parameters ¶ microseconds Halt time in microseconds. A...

    • Unpack

      Unpack data from binary string

    • Eval

      Evaluates the given code as PHP. The code being evaluated...

    • Defined

      Checks whether a constant with the given constant_name is...

    • Pack

      Pack given arguments into a binary string according to...

  2. PHP define () Function The define() function defines a constant at run-time. The define() function always define constants in the global scope, and can be declared inside conditional blocks (if/else, loops, functions), but they cannot be used to define class constants. Syntax

  3. Dec 31, 2020 · Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.

  4. Constants ¶ Table of Contents ¶ Syntax Predefined constants Magic constants A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script (except for magic constants, which aren't actually constants). Constants are case-sensitive. By convention, constant identifiers are always uppercase. Note: Prior to PHP 8.0.0 ...

  5. Oct 3, 2016 · Probably what is looked for when seeking a local constant within a PHP function is a storing facility which: has its own identifier is scoped and visible only within a function can’t be override during the function lifecycle always return the same value For that purpose, nested function represent an option that fulfills all these requirements.

  6. Jul 4, 2025 · PHP Constants are the identifiers that cannot be changed. Learn how to create a PHP Constant, and analyze pre-defined constants & Magic constants with examples

  7. People also ask

  8. In PHP, constants are used to define values that cannot be changed during the execution of a script. They are different from variables, as their values remain constant and immutable once defined. Constants are especially useful for storing fixed values like configuration options, mathematical constants, or any data that should remain unchanged. In this tutorial, we will cover: