Pass controller variable to the view

1

I put this as an example of what I want to do:

public function imagenPerfilusuarioController(){

    if(isset($_POST['btnmodimgu'])){


        $respuestaver=Datos::verimagenPerfilusuarioModel($datosController,"usuarios");

 if (isset($respuestaver['img_perfil_usuario'])) {
   $rutaimgv=$respuestaver['img_perfil_usuario'];
   unlink($rutaimgv);
  }


 }
}

In that function I want to remove the variable $ rutaimgv, to show it in the view, like the step up there?

in the view I call this function like this:

  $modificar = new Controller();
  $modificar -> imagenPerfilusuarioController();
    
asked by jorgnv 22.08.2017 в 02:11
source

1 answer

1

Try removing the unlink $ rutaimgv; and then return $ rutaimgv; inside your controller.

If the model returns the correct values to your controller and the instance of your class is correct, it should work by passing the function to a variable and calling it from anywhere.

$modificar = new Controller();
$rutaimgv = $modificar -> imagenPerfilusuarioController();
echo $rutaimgv;
    
answered by 22.08.2017 в 06:33