A phper from Xi'an told me a PHP test question a few days ago:
<? PHP
$ S = 'abc ';
If ($ S = 0)
Echo 'is zero <br> ';
Else
Echo 'is not zero <br> ';
?>
Many people have incorrect answers and think the answer is the output string "is not zero ". In fact, the correct answer should be the output string "is zero ".
The reason is actually simple. Because PHP is a weak language, it has no mandatory requirement for variables to be "defined first and then used, the variable type varies flexibly according to the value assignment type. This "flexibility" seems flexible, but it actually hides the hidden danger of errors. Although $ S = 'abc'; the statement defines the variable $ s as the string type, because in the IF ($ S = 0) Statement, $ S is compared with a numeric constant, therefore, $ S is implicitly converted to a numeric variable with a value of 0. Therefore, the result of comparing $ S = 0 is true.
This type of error is generally transferred from Java, C, and other languages to PhP developers, Because Java, C, and other languages are strongly typed languages, different types of variables and constants cannot be compared with each other. In this case, a syntax error is reported.
In fact, PHP developers do not have to pay attention to such issues. In PHP, there is also a strict comparison operator "=", which requires that the types of the comparison be consistent, write the preceding if ($ S = 0) statement as if ($ S = 0) to avoid the preceding errors.
The above question reminds us that we must pay attention to the variable type problem when using weak languages such as PHP. When defining a variable, you can assign an initial value to define its type at the same time. Currently, most newly developed languages, such as the Young C # language, are strongly typed. The aforementioned problems in PHP won't happen in C.
Interestingly, the phper of Xi'an mentioned the aforementioned test questions not to discuss technical issues, but to say that many of the current phper are self-taught and basic skills are poor, long-standing on the front-line of project development, the technical problems of some minor details are neglected, leading to some hidden and low-level errors, which are sometimes fatal.
In fact, I also noticed this problem early. At the beginning of the year, I chatted with a PHP programmer who had 4 years of experience in the TM group. He mentioned that he applied for a job at a company and got stuck at the test. If he is asked to answer these PHP pen questions in the PHP environment on the machine, it should not be a problem. If he is not sure, he can immediately write a code test, however, the written examination requires that all the knowledge be extracted from the human brain rather than from the computer. phper, who has four years of PHP programming experience, is dumb-eyed. In fact, most of those syntaxes are commonly used.
PHP and phper have a strange phenomenon. The demand and the programmer's supply conflicts are very prominent. php education and training are also very common in China, and many phper are self-developed, even with a piece of code, I began to step into the development stage. As a result, I did not establish a systematic knowledge system, and the basic knowledge was poor. Many people were still stuck in the process-oriented programming stage, and they were quite excited, it is said that they can solve all problems only by writing functions. Some people have never heard of the Framework in PHP. Naturally, object-oriented thinking is impossible.
PHP developers are still ambitious. They intend to build PHP into something similar to a Java virtual machine. It is not impossible to use PHP to develop desktop programs. However, the status quo is frustrating and worrying. The education cannot keep up, and phper cannot grow. The PHP building may only be a dog's nest.
I am a PHP programmer and instructor, but I am not planning to become a believer or martyr in PHP. I just want PHP to do something that can be done by myself, currently, it seems that it has excellent applications in the website construction and Internet fields, such as popular forums, web applications, SNS, and many other systems developed using PHP. At present, some enterprises have developed and applied some open-source PHP frameworks, which are also very good. I have never heard that php development is worse than Java and. net. We hope that PHP and phper will be well positioned and have a bright future in China.
Zhang Qing (mesh)
From mesh horizon: http://blog.why100000.com
Why 100,000 computer learning networks: http://www.why100000.com