且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将变量从一种方法传递到同一控制器Laravel中的另一种方法

更新时间:2023-11-23 10:35:10

尝试一下在第一个函数上,您有一些 variable 巫婆,您想将其传递给另一个函数\方法

Try this on the first function you have some variable witch you want to pass it to another function\method

除了您需要使用 $ this 以及您想通过 var 传递的其他方法的名称之外,还需要使用类似的方法.

Than you need to use $this and the name of the other method you'd like to pass the var too something like this.

public function oneFunction(){
    $variable = "this is pretty basic stuff in any language";
    $this->anotherFunction($variable)
}

public function anotherFunction($variable){
    dd($variable);
}