PHP block in HTML code
function x (){
$x = 'hello';
echo('<marquee direction="left" scrollamount="3" behavior="scroll" style="width:300px;
height: 15px; font-size: 11px;">');
echo $x;
echo'</marquee>';
}
<?php
echo x();
?>
The html file am using is a template i found online...any suggestions for what i should be checking?
Thanks!Here's what will make that work:
<?php
function x (){
$x = 'hello';
echo('<marquee direction="left" scrollamount="3" behavior="scroll" style="width:300px;
height: 15px; font-size: 11px;">');
echo $x;
echo'</marquee>';
}
x(); // Not echo, because the function doesn't return a value.
?>
Here's a slightly nicer version:
<?php
function x ($message){
$html = '<marquee direction="left" scrollamount="3" behavior="scroll" style="width:300px; height: 15px; font-size: 11px;">'.$message.'</marquee>';
return $html;
}
echo x('hello');
?>
Coupe of things about the code you pasted:
function x ()
must also be inside<?php
and?>
tags to be treated as php code.Your function x() is NOT returning anything so you need to call it as
x();
and not asecho x();
The function itself needs to be wrapper in the tags
精彩评论