Does PHP use this method to reference the variables in if to else? What should I do?

Source: Internet
Author: User
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; } 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.