To resolve variable names in PHP custom strings, you can customize the page title in the background. the custom content may contain variables, which are represented by {$ var, $ var indicates the variable name.
After the title field is saved to the database and extracted, it will not be used for parsing with the php variable name. it will directly output {$ var} instead of defining the string, when double quotation marks are used, {$ var} is automatically transformed into the corresponding variable content. here it is like a string defined by single quotation marks, so you need to parse it yourself.
Here, we use a regular expression to extract all {$ var} from the string and determine whether the corresponding variable exists. if so, replace the corresponding content with str_replace ().
The procedure is as follows:
$ Value) {if (isset ($ value) {$ title = str_replace ($ match [0] [$ key], $ value, $ title );}} echo $ title;