How do you connect data to string information in PHP?
Like in Java you’d have
String myString = "hello " + integerVar;
where integerVar is and integer variable; you’re using a + to connect the two. How do you do this in PHP?
Like in Java you’d have
String myString = "hello " + integerVar;
where integerVar is and integer variable; you’re using a + to connect the two. How do you do this in PHP?
PHP is very flexible…
// for scalars
$myString = "hello $integerVar"; // interpolation
$myString = "hello " . $integerVar; // concat
// for array
$myString = "hello {$integerVar[i][j]}"; // interpolation
You use a period (.) for concatenations in PHP.
$sVar = "Hello".$cName."!";