Php 返回深入嵌套在if-else控件结构中的变量?

Php 返回深入嵌套在if-else控件结构中的变量?,php,Php,如何返回深入嵌套在if-else结构中的变量,以便在另一个函数中使用,该函数根据第一个函数中返回的变量的结果更改程序流? 这是程序的基本结构,if和else语句可以包含更多的if-else语句,这就是我深入使用这个词的原因。如何在第二个函数中使用该变量 e、 g 或者,如果要调用函数2之外的第一个函数: function this_is_function_2($dothis) { if($dothis == 1) { //DO SOMETHING } els

如何返回深入嵌套在if-else结构中的变量,以便在另一个函数中使用,该函数根据第一个函数中返回的变量的结果更改程序流? 这是程序的基本结构,if和else语句可以包含更多的if-else语句,这就是我深入使用这个词的原因。如何在第二个函数中使用该变量

e、 g

或者,如果要调用函数2之外的第一个函数:

function this_is_function_2($dothis) {
    if($dothis == 1) {
       //DO SOMETHING
    }
    else {
       //DO SOMETHING
    }
}

$dothis = this_controls_function_2($flow);
this_is_function_2($dothis);
或者,如果要调用函数2之外的第一个函数:

function this_is_function_2($dothis) {
    if($dothis == 1) {
       //DO SOMETHING
    }
    else {
       //DO SOMETHING
    }
}

$dothis = this_controls_function_2($flow);
this_is_function_2($dothis);

或者直接从函数中读取返回的变量:

function this_is_function_2() {
    if(this_controls_function_2($flow) == 1) {
       //DO SOMETHING
    }
    else {
       //DO SOMETHING
    }
}
或者将变量标记为全局变量:

function this_controls_function_2($flow) {
    global $dothis;

    if($flow == 1) {
       $dothis = 1;
       return $dothis;
    }
    else {
       $dothis = 2;
       return $dothis;
    }
}

function this_is_function_2() {
    global $dothis;

    if($dothis == 1) {
       //DO SOMETHING
    }
    else {
       //DO SOMETHING
    }
}
为此,函数调用的顺序必须适合:

this_controls_function_2($flow);

/* ... */

this_is_function_2();

或者直接从函数中读取返回的变量:

function this_is_function_2() {
    if(this_controls_function_2($flow) == 1) {
       //DO SOMETHING
    }
    else {
       //DO SOMETHING
    }
}
或者将变量标记为全局变量:

function this_controls_function_2($flow) {
    global $dothis;

    if($flow == 1) {
       $dothis = 1;
       return $dothis;
    }
    else {
       $dothis = 2;
       return $dothis;
    }
}

function this_is_function_2() {
    global $dothis;

    if($dothis == 1) {
       //DO SOMETHING
    }
    else {
       //DO SOMETHING
    }
}
为此,函数调用的顺序必须适合:

this_controls_function_2($flow);

/* ... */

this_is_function_2();