Isn't the switch written like this? Where is the ssid?

Source: Internet
Author: User
Where can I find the problem ssid in other groups?

See this problem in other groups
Where is the ssid?

Reply content:

See this problem in other groups
Where is the ssid?

We can echo the output variables in some places, as shown in the following code.


  

In the results, we can find that,echo $filedStr;This step is not output.

At this time, you should read the official PHP documentation, why is this caused? the reason is the switch.

What is in the official PHP documentation? this is in English and of course Chinese. There is a sentence in it:

Attention if you have mixed types of value in one switch statemet it can make you some trouble

Of course, a solution is provided below:


   

It is mentioned in this blog that PHP uses dynamic type conversion.

The variable type of a dynamic language changes with the stored variable, that is, the variable type changes according to the specific environment.

When the value of $ value is 'ssid ', when case 0 is executed, it is converted to an integer and compared with it. because it is equal after conversion, it cannot match the subsequent 'ssid '.

Because of yourswitchMatching,caseIs an integer, which causesStringForced conversioninteger,ssidConvertint0, it does not matchcase 'ssid'Of

The ssid is definitely not matched.

Thank you for your answers.

// Only take the integer and floating point types starting with valid numbers and get the first illegal number as of the end... intval ('1234ssid '); // 1234 intval ('ssid'); // 0var_dump ('ssid '= 0); // so, here it is 'true ', the corresponding code segment will be executed. there is no chance to match the ssid again.

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.