0

From the view I passed the value i.e test(); to the controller

<select name="FUNCT_NAME">
    <option value="test();">
</select>

I loaded the concern helper already in which the concerned function is defined i.e.

if ( ! function_exists('test')){
   function test()
   {
      echo "Got here";
   }
}

Now in the concerned controller I received it as,

 $func_name   = $this->input->post('FUNCT_NAME'); //test();
    /*
      it gives me the name of the function i.e test();, not call that 
      function i.e. test(); declared in helper. Desired output Got here
   */
    print_r($func_name); 

Now I want to call the test(); in the helper which is not calling. Kindly share the key if any.

Raham
  • 4,781
  • 3
  • 24
  • 27

1 Answers1

0

You need to call function name with () scopes. For example :

$func_name = $_GET['func'];
function test(){
    echo 'aaaa';
}

echo $func_name();

Additioanlly, for more examples you can see here: Use Variable as Function Name in PHP

Tural Rzaxanov
  • 783
  • 1
  • 7
  • 16