如何创建$函数echo <div> PHP [关闭]

Hey I have a question that I can not seem to figure out, how can I make a $function echo a html markup like this code:

<div style="color: purple;">Hello</div>

I can not seem to get it. Here is the code I am using is not working:

$contactUs = echo <div style="color: green;">click here</div>;

How can I make my $function work?

$contactUs = '<div style="color: green;">click here</div>';
echo $contactUs; 

Not really sure what you're asking about, but you can do:

$function = function() { echo '<div style="color: green;">click here</div>'; };
...
$function();

1° In php, all strings need to be surrounded by quotes:

'<div style="color: green;">click here</div>';

Then, echo is a language construct which send text to output (your screen for example);

// If you want to use a variable
$contactUs = '<div style="color: green;">click here</div>';
echo $contactUs;

// but you can use echo 'your string':
echo '<div style="color: green;">click here</div>';