$so = file_get_contents(...) ;
$so = preg_replace("/\*([^*]+)\*/e", constant(\1), $so) ;
trying to replace text between asterisks with constants of the same name but I keep getting an
unexpected T_LNUMBER. What am I writing wrong? I verified the existence of $so as a string, and all the constants exist as they are plain text.
I probably won’t use this script but I was curious what I’m messing up
The problem is with how the code is evaluated.
The line:
Should be:
You need to enclose the value passed to
constant()in quotes so it is treated as a string. Furthermore, enclose the second argument in quotes so the backreferences are evaluated.