-6
<?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")
?>

What's the trouble with my Function?

KB22
  • 6,899
  • 9
  • 43
  • 52
ROBOT
  • 1
  • 2
  • There is no trouble with function. No syntax errors in function. Not really sure what your problem is (I mean, I AM sure, but YOU don't said what you want to get, what you get and what problem is :P). Only syntax error there is is outside function. Each `echo` needs `;` at the end of line – Forien Dec 30 '14 at 09:08
  • What error you get? What do you expect the function should do? – bish Dec 30 '14 at 09:09
  • Trouble is that there's no `;` after first call – u_mulder Dec 30 '14 at 09:09
  • Please edit the php code! – ROBOT Dec 30 '14 at 09:11
  • Please READ YOUR ERROR.... jeez. You said nothing about what your problem is, just posted random code and expect us to be slaves. And you didn't even tried to check what error is... – Forien Dec 30 '14 at 09:11
  • Plus, tons of people blindly answered already with fixing 4 mistakes in your code.. so yeah.. – Forien Dec 30 '14 at 09:12
  • It gives a white page! – ROBOT Dec 30 '14 at 09:13
  • look in your error log.... – Eugen Dec 30 '14 at 09:14
  • Just as @Eugen said, or add `error_reporting(E_ALL);` at beginning of your code. Or modify `httpd.conf` file in your server config if you have access to – Forien Dec 30 '14 at 09:14
  • I got thousand answers `;` was not there. Thank you all – ROBOT Dec 30 '14 at 09:14

3 Answers3

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");
?>
Eugen
  • 1,356
  • 12
  • 15
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");
?>
Arash
  • 155
  • 5
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");

?>

sandipon
  • 986
  • 1
  • 6
  • 19