-2

I am trying to pass variables when calling a method. I am trying to do something like this:

 $c->house_num.$id($name);

The name of the method is house_num_(number). I then want to pass another variable $name.

I am getting an error, what is the right way to do this? Thankyou

Ryan
  • 29
  • 1
  • 4

2 Answers2

1
$c->house_num($id,$name);

And then use somthing like

function house_num($id,$name){
switch($id){
 //call functions...
}
itay
  • 357
  • 4
  • 16
0

you should be use that :

$func = 'house_num_'.$id;

$c->$func($name);
Lucas Burg
  • 87
  • 1
  • 1
  • 5