Print from a function.

I’ve got to be overlooking something ever so simple. I’m trying to print a message from a function, and I can’t get it to print. Where did I go wrong?

[php]<?php

function greeting() {
$msg=“The message goes here.”;
print $msg;
}

?>[/php]

I’ve taken the double quotes and substituted single quotes. I put the print line outside of the function line,

[php]<?php

function greeting() {
$msg=“The message goes here.”;
}

print $msg;

?>[/php]

I make a call to the function

[php]

<?php greeting(); ?>[/php]

Somewhere along the line, I just don’t know what I am doing wrong.

Hello,

Have you tried using echo instead of print?

Cheers!

[php]<?php

function greeting() {
$msg=“The message goes here.”;
print $msg;
}

greeting();[/php]

Just for the record, that will never ever matter never ever.

While I understand what you are trying to accomplish,

Is better than having the function print anything.

Sponsor our Newsletter | Privacy Policy | Terms of Service