newbie question: what's wrong on this code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xan7
Forum Newbie
Posts: 2
Joined: Thu Dec 19, 2002 9:10 am

newbie question: what's wrong on this code?

Post 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 :)
User avatar
nathus
Forum Commoner
Posts: 49
Joined: Thu Dec 12, 2002 6:23 pm

Post 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; 

?>
xan7
Forum Newbie
Posts: 2
Joined: Thu Dec 19, 2002 9:10 am

Post by xan7 »

that was it. thanks alot :)
Post Reply