Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change value of a defined constant? [duplicate]

Tags:

php

constants

Possible Duplicate:
Change the value of a previously-defined constant

There is a constant ABC and I need to get its value, save it, change, do some actions and restore. But I was told that it isn't possible. Please, tell me, is it true? If no, tell me, how can I get value from a constant and set my value for it?

like image 424
user1477886 Avatar asked Oct 07 '22 09:10

user1477886


1 Answers

This is not possible. The point of a constant is to not be changed, and once a constant is defined it cannot be redefined or deleted.

However there are options. You could use normal variables or maybe this can be helpfull in some way: Un-define constants with define/apc_define_constants in PHP

According to that post you can use the apc_* functions to undefine and define it. So you can change it in the fashion of deleting it, and creating it again with a new value.

like image 138
Henrik Skogmo Avatar answered Oct 12 '22 11:10

Henrik Skogmo