Page 1 of 1

newbie question: what's wrong on this code?

Posted: Thu Dec 19, 2002 9:10 am
by xan7
hi there, I'm just starting to learn php and I've got the first problem.
what's wrong on this code?:

<?php

function make_b(&$html)
{
$html = Array("<b>",$html,"</b>");
}
$html = "Test";
list($opentag,$html,$closetag) = make_b($html);
echo $opentag.$html.$closetag;

?>


thanks for any helpful hints,
xant :)

Posted: Thu Dec 19, 2002 9:23 am
by nathus
list($opentag,$html,$closetag) = make_b($html);

on this line, the make_b($html) has no value, as there is no return in the function.

Code: Select all

<?php 

function make_b($html) 
{ 
  $html = Array("<b>","$html","</b>");
  return $html; 
} 
$html = "Test"; 
list($opentag,$html,$closetag) = make_b($html); 
echo $opentag.$html.$closetag; 

?>

Posted: Thu Dec 19, 2002 9:27 am
by xan7
that was it. thanks alot :)