function Multiply($x, $y)
    echo $x * $y;

echo 'Multiply : '.Multiply(2,3).'<br><br>';




Why the result of the above program is :

6Multiply :

instead of

Multiply : 6

Any clue?

Recommended Answers

All 2 Replies

In this example it's all about order of execution. Line will have to call Multiply() to make the output string and since your function echo'd something then your example shall echo the mulitiple first then your line 14 text is output.

I see no mystery here at all.

change your function to return the value instead of echo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.