How to append a string in PHP
Topic: PHP / MySQLPrev|Next
Answer: Use the PHP String Operators
There is no specific function to append a string in PHP. But you can use the PHP concatenation assignment operator (
.=) to append a string with another string.
Let's check out the following example to understand how it basically works:
ExampleRun this code »
<?php $a = "Hello"; $a .= " World!"; echo $a; // Outputs: Hello World! ?>
See the tutorial on PHP operators to learn about the operators in detail.
Here are some more FAQ related to this topic:
- How append a string in PHP
- How to combine two strings in PHP
- How to create a string by joining the values of an array in PHP