The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Format question: why is fetch_template surrounded with single quote+period?
Hello,
Can anyone explain why the format for fetching templates includes the template name enclosed in single quotes and periods? eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('WHOSONLINE') . '");'); Thank you, R |
#2
|
||||
|
||||
String Concatenation
|
#3
|
|||
|
|||
you could also make it this way:
eval(print_output(fetch_template('WHOSONLINE'))); but only if your server is PHP 5.1 and newer... it would not be compatible with older versions, so it would break a lot of vBulletin right now... in the future, this structure will change... |
#4
|
|||
|
|||
I thought it might be it, but I still can't see how it works in this case.
Why are there single quotes inside the double quotes? Which string does this concatenate to? Why not use the .= format? |
#5
|
|||
|
|||
Work from the inside out...
The start of this page shows the differences between single & double quotes and may help to explain why there are double quotes inside single quotes. Its not hard to understand but if you are not well versed in PHP could take a while to explain it fully. |
#6
|
||||
|
||||
Because you can't. There isn't a "=" anywhere, so you can't use a ".=".
|
#7
|
|||
|
|||
First, thank you all for replying. I've read the guide on single and double quotes, and understood it, including the concatenation examples.
Now, if we take just this part: $navbar = "' . fetch_template('navbar') . '"; I fail to understand why it isn't written as: $navbar .= "fetch_template('navbar')"; Also, seeing as how PHP would recognize a function inside quotes as a string (I'm talking about 'fetch_template...'), does eval overcome this by treating everything to the right of it as possible PHP code? Thank you, R |
#8
|
||||
|
||||
That's different. eval() does indeed parse everything as PHP code. fetch_template() parses templates from the conditionals to proper PHP code which can be understood. We are concatenating fetch_template()'s output to $navbar, what you suggest is concatenating fetch_template()'s output to the end of navbar, and what will be concatenated will be the PHP code that fetch_template() outputs, and that will not be parsed by eval().
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|