Quantcast
Channel: User naththedeveloper - Stack Overflow
Viewing all articles
Browse latest Browse all 41

Answer by naththedeveloper for PHP string number concatenation messed up

$
0
0

The dot operator has the same precedence as + and -, which can yield unexpected results.

That technically answers your question... if you want numbers to be treated as numbers during concatenation, just wrap them in parentheses.

<?php    echo '11hello ' . (1 + 2) . '34';?>

Viewing all articles
Browse latest Browse all 41

Latest Images

Trending Articles





Latest Images