Welcome Guest, Not a member yet? Register   Sign In
Pass variable trough functions
#1

[eluser]Fantass[/eluser]
Hello!, well this is quick question but i dont have a clue how to solve


i want to do the next (example)

Code:
<?
class some extends CI_Class{
  
function index()
{
   $variable = 'hello world'; //some X variable
   $variabletopass = $variable; //the variable that i need to pass through.
}
function misc()
{
    $some = $this->index($variabletopass); //this is what im trying but i dont get nothing
    var_dump($some);
}
}

OUTPUT = undefined variable. Boolean Null.

I hope someone could help me thanks alooot!!

Best regards
#2

[eluser]InsiteFX[/eluser]
Code:
class some extends CI_Class {

    public $variabletopass = '';

    function index()
    {
        $variable = 'hello world'; //some X variable
        $this->variabletopass = $variable; //the variable that i need to pass through.
    }

    function misc()
    {
        $some = $this->$variabletopass; //this is what im trying but i dont get nothing
        var_dump($some);
    }
}
#3

[eluser]Fantass[/eluser]
Awesome! thanks alot dude!




Theme © iAndrew 2016 - Forum software by © MyBB