Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you undefine or change a constant in PHP?

Tags:

php

constants

Can you undefine or change a constant in PHP?

like image 616
TheConstantGardener Avatar asked Jun 23 '11 14:06

TheConstantGardener


People also ask

Can constants be changed PHP?

A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or underscore (no $ sign before the constant name).

How do you change the value of a constant?

Changing Value of a const variable through pointerBy assigning the address of the variable to a non-constant pointer, We are casting a constant variable to a non-constant pointer. The compiler will give warning while typecasting and will discard the const qualifier.

Can a constant be undefined in PHP?

Using a constant that's not defined in this version of PHP, or is defined in an extension that's not installed. There are some system-defined constants that only exist in newer versions of PHP, for example the mode option constants for round() such as PHP_ROUND_HALF_DOWN only exist in PHP 5.3 or later. Thanks for share ...

Can we change the value of constant during the execution of the script?

A constant value cannot change during the execution of the script. By default, a constant is case-sensitive. By convention, constant identifiers are always uppercase.


1 Answers

No. Constants are constant.

Reference: php.net/manual/language.constants.php

like image 61
George Cummins Avatar answered Sep 21 '22 14:09

George Cummins