麻烦PHP函数,传递参数

时间:2014-12-30 09:06:49

标签: php function

<?php
function setFont($text, $name, $size){
 return "<div style='font-family: ".$name.";font-size: ".$size."'>".$text."</div>";
}

echo setFont("Hello", "tahoma", "19")
echo setFont("Welcome", "tahoma", "19")
?>

我的功能有什么问题?

3 个答案:

答案 0 :(得分:1)

<?php
function setFont($text, $name, $size){
 return "<div style='font-family: $name ;font-size: $size'>".$text."</div>";
}

echo setFont("Hello", "tahoma", "19");
echo setFont("Welcome", "tahoma", "19");
?>

答案 1 :(得分:1)

<?php
function setFont($text, $name, $size){
 return "<div style='font-family:$name;font-size:".$size."px'>".$text."</div>";
}

echo setFont("Hello", "tahoma", "19");
echo setFont("Welcome", "tahoma", "19");
?>

答案 2 :(得分:0)

<?php
function setFont($text, $name, $size){
return "<div style='font-family: ".$name.";font-size: ".$size."'>".$text."</div>";
}

echo setFont("Hello", "tahoma", "19");
echo setFont("Welcome", "tahoma", "19");

&GT;