+ 3
PHP constant error
https://code.sololearn.com/w2zJh1wPBMqf/?ref=app This code have error, Any one help me and explain What is the reason for error.....
6 Answers
+ 5
Manimaran K As Igor Makarsky mentioned, you'll need to use the define function to create a constant from another variable value at runtime:
In your case, replace the line:
const word1 = $name;
with:
define("word1", $name);
+ 16
Why do you need to assign a variable to a constant?
You can use define() instead.
+ 15
You can't assign a variable to a class constant, because the value must be a constant expression, not (for example) a variable, a property, or a function call.Â
See more:
https://www.php.net/manual/en/language.oop5.constants.php
+ 5
in php you cant initialize a constant variable with any other variable...but const can initialize another const...
+ 3
Thank you all đ„
+ 2
Nice answers....But how can i achieve this process đŁâčïž