Search code examples
phpstring-concatenation

concat of strings echos in wrong order


I have a class

$page=new page;

with function,

header() {
echo 'blah blah';
}

now if I concat two strings together like,

$string= "";
$string .= " 1234";
$string .= $page->header();
echo $string;

results in,

blah blah 1234

how can I get it in the correct order?


Solution

  • You're just echoing the string.

    your header() function should return a string:

    function header() {
        return 'blah blah';
    }