Q:

How to prepend a string in PHP

0

How to prepend a string in PHP

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the PHP Concatenation Operator

There is no specific function to prepend a string in PHP. But you can use the PHP concatenation operator (.) to prepened a string with another string.

Let's take a look at the following example to understand how it basically works:

<?php
$a = "Hello";
$b = "World!";
$b = $a . " " . $b;
echo $b; // Outputs: Hello World!
?>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP  and MySQL Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How append a string in PHP... >>
<< How to remove HTML special characters from a strin...