Switch. case discourse call time parameter program error troubleshooting

Source: Internet
Author: User
The call time parameter program of the switch... case statement fails to solve the problem. Switch ..... the case statement has become the most common choice statement with high interest rates and convenience. as we all know about the stristr function, it is a good idea to combine the two statements to write parameters at the current time, solve the problem during debugging: & lt ;? Phpdate_default_timezone_set (AsiaShangHai); $ hd switch... case statement call time parameter program error solved.
Switch ..... the case statement has become the most common choice statement with high interest rates and convenience. as we all know about the stristr function, it is a good idea to combine the two statements to write parameters at the current time, solve the problem during debugging:
Date_default_timezone_set ("Asia/ShangHai ");
$ H = date ("H: I ");
Echo $ h; // output the current time;
Switch ($ h ){

Case ""; // you can take any time for debugging;
If ($ k = "12:00 ");
If (stristr ($ k, $ h )! = "");
Echo "successful ";
Break;
Case "12: 01 ";
If ($ k = "12:01 ");
If (stristr ($ k, $ h )! = "");
Echo "succeeded again ";
Break;
Default:
Echo "failed ";
}

?>
Errors occur frequently during debugging. please answer the question. thank you.

------ Solution --------------------
You $ h = date ("H: I ");
There is a space before the time.
So it will not enter any branch like case "12:01"; because there is no leading space

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.