0

I'm trying to define a constant but it breaks my script. I can define it in a standard varible absoloutly fine, without errors but as soon as I try to define it with the const function it no longer works, here is my code.

const CURRENT_URL = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

Brad Fletcher
  • 3,547
  • 3
  • 27
  • 42
  • 1
    From the [manual](https://www.php.net/manual/en/language.oop5.constants.php): "The value must be a constant expression, not (for example) a variable, a property, or a function call." – Nick Apr 01 '20 at 11:53
  • As PHP Manual saya : 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). A constant is case-sensitive by default. By convention, constant identifiers are always uppercase. – Umar Farooque Khan Apr 01 '20 at 12:25

0 Answers0