assumed i define a variable like this:
<?php
define("page", "actual-page");
?>
now i have to change this content from actual-page
to second-page
how can i realize that?
i try the following methods:
<?php
// method 1
page = "second-page";
// method 2
define("page", "second-page");
// method 3
unset(page);
define("page", "second-page");
?>
now my ideas goes out... what can i do else?
No, you cannot redefine a constant (except with runkit_constant_redefine), that's why is called CONSTANT. Short answer: No.
unset() destroys the specified variables. The behavior of unset() inside of a function can vary depending on what type of variable you are attempting to destroy. If a globalized variable is unset() inside of a function, only the local variable is destroyed.
The point of a constant is, that they cannot be changed. You should use a true variable instead. Save this answer.
The unset() function is an inbuilt function in PHP which is used to unset a specified variable.
When you use PHP's define() function, you're not defining a variable, you're defining a constant. Constants can't have their value modified once the script starts executing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With