Welcome Guest, Not a member yet? Register   Sign In
Calling Controllers Functions with function name in a php variable
#1

[eluser]ReSTe[/eluser]
Hi all...

I've a problem:

i have a variable named backpergest2 that contains the name of a function of my controller.
The idea is that i'm in a controller function and i've to call another controller function (backpergest2=name of controller function that i've to call)...

i've tried this code:

$this->$backpergest2;

but php shows me the following error:

Severity: Notice

Message: Undefined property: Tmfmagenta::$visualizzaprocspec()

Filename: controllers/tmfmagenta.php

Line Number: 18103


as u can see the name of the function that i've to call is visualizzaprocspec() and it is also the content of the variable $backpergest2.

what can i do?

thanks a lot, and greetings from italy Smile

Matteo

PS: the function visualizzaprocspec() exist in the controller.
#2

[eluser]gtech[/eluser]
I tried somthing similar as a test for you and it worked.. create a controller called test.php copy the code and give it a go!
Code:
<?php
class Test extends Controller {

  function Test()
  {
    parent::Controller();
  }
  function start($func='myname')
  {
    echo "hello";
    $this->$func();
  }
  function myname()
  {
    echo " gtech";
  }
}
?>

result
Code:
hello gtech

Or are you trying to do something different? you may just have a typo (typing error) somewhere.
#3

[eluser]ReSTe[/eluser]
yeah it works!!!

wonderful Smile

my error was in the content of the variable

bad variable: $var="visualizzaprocspec()"

right variable: $var="visualizzaprocspec"

stupid "()" Big Grin Big Grin Big Grin

thanks a lot u have helped me with my thesis.

thanksthanksthanks

Matteo.
#4

[eluser]gtech[/eluser]
cool, glad to of helped.




Theme © iAndrew 2016 - Forum software by © MyBB