Smarty3 - String Concatenation

1,654 views
Skip to first unread message

Matt

unread,
Nov 19, 2009, 3:00:20 AM11/19/09
to Smarty Developers
I have the latest svn snapshot, and I have the following issue with
concatenation:

Code:
{$test = "one" & "two"}
{$test}

Output:
dfe

Not the expected output, as far as I know.

Matt

a...@ewelike.com

unread,
Nov 20, 2009, 7:19:05 AM11/20/09
to Smarty Developers
I guess by now you realised that this is the same output as straight
PHP off the command-line:
$ php -r 'echo "one" & "two";'

(the result is a bitwise AND on the ASCII values of each character)

I think you have to use the |cat modifier as Smarty uses '.' for array
keys instead of as a standard PHP concatenation operator.

Ash

Deebster

unread,
Nov 20, 2009, 4:26:44 AM11/20/09
to Smarty Developers
This looks fine to me as & is the bitwise AND operator:
http://uk2.php.net/manual/en/language.operators.bitwise.php

1101111 & // o
1110100 == // t
1100100 ; // d

This is Smarty concatenation:
{"one"|cat:"two"}


On Nov 19, 8:00 am, Matt <m...@frigidmedia.com> wrote:

Uwe.Tews

unread,
Nov 21, 2009, 7:18:56 AM11/21/09
to Smarty Developers
The "&" operator was changed back as bitwise AND operator for Smarty2
BC.

For string concatenation use the cat modifier or use the posiibilities
of double qouted strings.

Anderson A. Meggiolaro

unread,
Nov 23, 2009, 5:56:33 AM11/23/09
to smarty-d...@googlegroups.com

Hi, concatanation with cat modifier is really hard and painfull to do for me, especially when you have a lot of variables. What is the problem of allowing concatenation with '.' , like "ONE" . "TWO"?

regards.



2009/11/21 Uwe.Tews <uwe....@googlemail.com>
--

You received this message because you are subscribed to the Google Groups "Smarty Developers" group.
To post to this group, send email to smarty-d...@googlegroups.com.
To unsubscribe from this group, send email to smarty-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/smarty-developers?hl=.





--
------------------------------------------------
Anderson A. Meggiolaro
IT Developer
Follow me at http://twitter.com/ameggiolaro
------------------------------------------------

Monte Ohrt

unread,
Nov 23, 2009, 10:06:19 AM11/23/09
to smarty-d...@googlegroups.com
dot "." is already used for array key access. You can cat several ways:

"$foo$bar"
{$foo}{$bar}
$foo|cat:$bar

Otherwise we would need to come up with a new concatenation character.
Reply all
Reply to author
Forward
0 new messages