PHP String Concatenation

PHP string concatenation

Just use . for concatenating.
And you missed out the $personCount increment!

while ($personCount < 10) {
$result .= $personCount . ' people';
$personCount++;
}

echo $result;

Concatenating strings having dot(period) in php

If the variables contains eg. space, they has to be in quotes. Concat operators cause no problem.

echo "<input type='text' value='" . $value . "' name='" . $input_id . "'/>";

PHP left string concatenation operator?

The closest thing to a built-in function would be using strpad like

$a = str_pad($a, strlen($a)+strlen("b"), "b", STR_PAD_LEFT);

but as others have pointed out its much simpler to just do $a = "b" . $a;

PHP syntax error for concatenation of string with the . operator

try this query:

$sqlCheckUser = "SELECT * FROM `user` where `email` = '".$email ."' OR `username` = '".$username ."'";


Related Topics



Leave a reply



Submit