Calling function from inside echo

I have created a function which I think will work:


function myUserPass(){
if ($row['FirstName'] == ""); {
echo "<img width=11px src='../site_images/Cross.jpg' />";
}
}

I have an echo function going on, and want to call this function from inside it, but I’m not getting something as all it is doing is writing the function name to the website.


echo "Password: [$myUserPass()]";

In the example above, the calling of the function, which has been reduced considerably for this post is just writing “()” to the website, when I want the image to show.


function myUserPass(){

if ($row['FirstName'] == ""); {
return "<img width=11px src='../site_images/Cross.jpg' />";
}



}

Usually best to have your functions return data (in this case a string) and decide to echo it nearer the end of its journey.


echo "Password: " . myUserPass() ;

That leaves the door open to doing things like this:


$message = "<h3>Hello!</h3>";

// then some stuff

// then concatenate more info to the message
$message .= "Password: " . myUserPass() ;


// then finally, in a place in your code that makes more sense to echo stuff out:

if( $logged_in ){
echo $message;
}