Does PHP use this method to reference the variables in if to else? For example, thank you ------ solution -------------------- do not understand what you mean ------ solution ------------------ PHPcode $ test1; if ($ test) {$ test2;} else {# Here I want to output $ test2? Does PHP use this method to reference the variables in if to else?
For example, thank you.
------ Solution --------------------
Don't understand what you mean
------ Solution --------------------
PHP code
$ Test = 1; if ($ test) {$ test = 2;} else {# here you want to output $ test = 2? Echo $ test; # In addition to re-assigning values, you can't think of other methods, because in this case, if, else is unnecessary}
------ Solution --------------------
If ($ a ++ ){
} Else {
Echo $;
}
------ Solution --------------------
Use goto to jump into if ...... Jump back after the assignment statement ......
A bit X
------ Solution --------------------
The question you asked about the 'If structure is messy 'is the same. don't think about it. use session. Otherwise, it's hard to figure it out, the values passed in the form cannot return data.
However, my experiments over the past few days have concluded that the common variables defined in IF cannot be passed out. IF a policy is found, I hope to post it and share it. I also want to learn it.
Ideas:
Session_start ()
Then $ _ session ['Your VAL'] = $ val;
The following code outputs $ _ SESSION ['newval'] = 3, $ str =;
Echo '$ str ='. $ str;
PHP code
session_start(); global $str;$test='vcd' ; if ($test==='vc') { $str=$_SESSION['newval'] =3 ; $str=$_SESSION['newval'] ; echo '$str='.$str; }else{ // session_start(); echo '$_SESSION['.'newval'.']='. $_SESSION['newval'] ; echo '$str='.$str; }