I need in smarty template to transmit to function concatenated string constant with variable value, How can i do it?
some example code:
{$obj->calledFunc('string const').$var}
but . operator doesn't work
Concatenation is the process of appending one string to the end of another string. You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
Using the + operator is the most common way to concatenate two strings in Java. You can provide either a variable, a number, or a String literal (which is always surrounded by double quotes). Be sure to add a space so that when the combined string is printed, its words are separated properly.
To concatenate use the + between values. To use the Variable with String Concatenation Pattern a variable is defined which stores the value of a string combined with another string or number.
In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" and "ball" is "snowball". In certain formalisations of concatenation theory, also called string theory, string concatenation is a primitive notion.
Use the cat modifier:
{$obj->calledFunc('string const')|cat:$var}
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