In order to reduce PHP beginners from detours. so suddenly nervous. I decided to write this article. for PHP beginners only. if any error occurs. also hope to point out. I am not very grateful. as an intermediate PHPer Cainiao .. if you are bored, you will be confused on various PHP forums. many PHP beginners have asked the same question. I also met PHP when I was learning PHP. in order to reduce PHP beginners from detours. so suddenly nervous. I decided to write this article. for PHP beginners only. if any error occurs. also hope to point out. I am not very grateful.
PHP is actually a simple and easy-to-learn language. if you want to master PHP for more than three years, it will be enough. But why are we still Cainiao three years later?
I don't know where to start. to learn PHP, we have to learn the database. learning architecture. learning object-oriented. learning front-end. learn about linux. learning protocols and even artists directly lead to PHPer being the most tiring programmer.
The most tiring is nothing. PHP is often considered to be a lower-level program. it is unfair to have a minimum salary but almost all the web knowledge.
Fortunately, we gradually see a change in China. more and more companies in China have switched from Java or C # to PHP. therefore, PHPer must have their own dreams. you will be awesome. please firmly believe.
Far away. back to the point I want to talk about. the following questions contain my problems. maybe I'm not necessarily right or you don't necessarily agree with me. I am very willing to accept your comments. in short, we just want to make all PHPer available :-)
1. encoding problems This is not just PHP .. as long as it is on the program. this will happen. at least I met people around me. in addition, in terms of Web. it is often difficult to solve the encoding problem. difficult to debug. sometimes the program has an inexplicable problem, and it is hard to think of a problem with coding.
These problems are always bothering us. so I suggest PHP beginners. unified encoding is required. and it is strongly recommended to unify the UTF-8. GBK or GB2312 is not recommended for Chinese characters. this encoding is not recognized during AJAX transmission.
If you want to unify the encoding, you should pay attention to it wherever the encoding may occur.
1) header encoding
I personally suggest you add the following sentence in your PHP (except for special headers)
The code is as follows:
Header ("Content-type: text/html; charset = utf-8 ");
This avoids some problems. for example, we can see that some websites submit an alert and jump to it. but they didn't set the encoding. if the encoding is inconsistent with the default encoding of the browser. garbled characters will appear.
You are pure HTML. remember to put the encoding tag of meta in front of the title tag. if you don't understand it, remember to put the encoding information in the first line of the head tag. the final result is as follows:
The code is as follows:
...
2) file encoding
We save the file, select encoding must be unified. if according to the above. we should select UTF-8.
The general editor has the encoding information for this file. if you find it is not a UTF-8. change it immediately.
For example, we opened a template file in Dreamweaver and found that the lower right corner of the display GB2312 (simplified Chinese). do not make any changes at this time. right away CTRL + J then select the encoding to change to UTF-8 mode and save.
File encoding is not necessarily php file. you have to ensure that your JavaScript file and css file are both UTF-8 encoding.
Another important point is that. is BOM .. this Dongdong PHP is not very popular. so we have to choose UTF-8 without BOM format when saving. if the editor you use is UE. pay attention to this point.
3) database encoding
I don't want to talk about it anymore. there are too many articles on the Internet. if you are using MySQL, remember to set names = 'utf8' after each connection. and there is no crossline in the middle of the utf8.
2. MVC problems Programmers should be perfectionists in theory. they don't just want to write and run the program, but they also need elegance.
But let's talk about it. will our code be elegant after the program is implemented according to MVC? Of course, the answer is No.
Learning architecture is a process of understanding. when you really appreciate the benefits of this architecture, you will understand its true meaning. do not blindly.
Sometimes we will make such a plan. use this month to learn MVC. okay. I think you should do this. you have learned to set your own goals.
But a month later, we may not really understand MVC .. but at least we will follow his pattern. in other words, we may not have learned the sunflower collection. but we should have used the evil sword.
3. object-oriented issues Some people do not think PHP object-oriented is a good thing. some people do not even think that object-oriented is a good thing, such as Linus.
We don't have to get stuck with this thing. at least we should know from the emergence of object-oriented systems to the present. after so many years of evolution. it applies to various projects and even languages. we have reason to believe that there is truth.
Practice is the only criterion for testing truth. the more object-oriented development over the years, the better the situation. it seems that learning has become a necessity.
Similar to some architecture knowledge, object-oriented is not so studious. object-oriented is a kind of concept. but when it comes to a language, its meaning will also change slightly.
PHP's object-oriented method is flexible. coupled with its unique magic method, it will create a special situation of object-oriented. maybe this is not the same as Java's object-oriented method.
Not always put the methods you need into a class as object-oriented. when you really realize that object-oriented coding brings speed to your coding. convenience. you have a deeper understanding of object-oriented.
The so-called speed is not up. do not worry. you want to understand the theory of relativity in a few days is purely nonsense.
4. algorithm problems It seems that PHP and algorithms are always far from each other. most PHP algorithms are implemented based on arrays. we know that the PHP array feature is doomed when the array becomes very large. efficiency will decrease.
In fact, PHP is a website. you don't have to give her a big hat. in terms of Web, especially in the case of the front-end of PHP services, there will be very few algorithms involved.
PHP's algorithm interview questions are nothing more than operations on arrays or strings... move your mind to add a manual. that's basically okay.
Then you may ask. I want to learn PHP. Will I still learn algorithms?
I think you need to learn and learn data structures. This course is like an internal task. it will influence your coding in a subtle way.
At this time, we will cooperate with the previous evil sword. Congratulations, you have learned the sunflower collection!
5. framework problems The PHP framework is the most popular among various languages. it is a controversial topic to choose a framework without framework ..
My suggestion is that we recommend learning at least one framework, which can deepen your understanding of PHP. our learning framework does not mean learning how to use this framework and how to build projects.
Let's take a look at its source code and see how it is implemented. at this time, you can develop a small framework by yourself. you don't want to do well. you don't want to use other people's projects.
We just want to learn.
6. JavaScript problems It can be said that I have seen so many languages. the most amazing thing is JavaScript. Java has always declared that everything is an object. In fact, I think JavaScript is everything.
Is JavaScript good? Learn! In fact, when using the Web, the general JavaScript operation is DOM operation.
Is JavaScript hard to learn? Hard to learn! If we are bound by the object-oriented thinking of other languages, it is difficult to understand the object-oriented thinking of JavaScript, and there are many concepts in JavaScript.
Prototype arguments call apply callee caller closure and other concepts make us feel overwhelmed. In addition, the strange JavaScript code style and the difficult debugging features directly lead us these Cainiao to avoid it.
I once forwarded a piece of code to implement document. ready. I had to admire it to a strange degree.
I personally think that reading the source code of some JavaScript frameworks is the best way to learn. I used to write my PHP framework. the unified entry + custom URL rules are used. therefore, when you use a form with the common attribute "get", the parameter cannot be obtained.
At this time, I thought of the formSerialize method in jQuery. form. I picked it out and made some modifications to use it.
7. CSS problems I separate CSS from JavaScript. I think CSS learning is more characteristic.
In fact, CSS is the simplest thing. we only know some basic CSS attributes. writing a page is definitely not a problem.
The main feature of CSS is that you have to do it. it is better to read n css books to write a page.
Another feature of CSS is to try it more. maybe this attribute cannot achieve your effect. then you should change it. this is also the most stupid and most effective method :-)
Of course, this is only the requirement of junior CSS. after that, we have to be compatible with browsers. In fact, it is not difficult to try to open a property and an attribute in several browsers at the same time.
You can also memorize some hack, for example, IE6 knows _ IE knows * and so on. if you think this kind of writing is not standard enough, then you can put hackers' into different CSS files. ie6.css stands for ie6.css if it is like IE6.
Then you can use the following code on the page.
The code is as follows:
More advanced, of course, is the user experience and design. if I do not understand this, I will not talk about it.
8. linux problems I strongly recommend that you install a linux system on your computer. if you think it is too difficult, you can choose the wubi method to install Ubuntu. this is the simplest and most effective method for lazy people.
When you are bored, you can download a PHP source code and compile it by yourself. do not use apt-get. because the server version is usually neither rhel nor centos. This command is unavailable.
Apt-get is often not the latest version and cannot be customized by itself.
In linux, there will always be such an inexplicable problem. for example, if the environment is slightly different, the compilation will not pass. The service will not start.
In this case, do not worry. check the error message to see the log. Google will try to solve it.
Do not try different configurations after compilation, and modify the source code before compiling.
For example, we downloaded the nginx source code and modified some headers to compile an HTTP Web Server.
Of course, if you call it BWS or GWS, do the following :-)
There is another problem: does linux need to back up the command? This is understandable. Note that some common commands can improve the speed. I need to reflect on this. you need to take a look at the parameters for some frequently used commands ..
Another issue is Shell. shell is not difficult. however, the syntax seems ugly to me @_@. take a look at the wiki to learn more than half of it .. contact me. we can see a phenomenon. some companies are also listed as mandatory when recruiting advanced PHPer.
In fact, there are a lot of documents about linux on the internet. most of the problems you encounter will be encountered by others. so they are good at Google and are familiar with English.
9. language problems There are too many verbal battles about this problem. no one will beat anyone in the end. we don't have to participate in these boring things. these are all what the young man has to do.
Do you have Linus niub? He sprayed C ++ for so many years. how about C ++?
So we don't have to worry about this. just do what we do.
Since you have chosen PHP, don't hesitate.
Maybe PHP is not enough for the project. we can use Java or C to build a middleware.
The truth is the greatest use of a language.
10. attitudes Attitude must be modest and cautious. this is a virtue a programmer should have. do not expand yourself.
The more you learn, the more you will find that you are insufficient.
When you get B, you can say something arrogant. but now we are not good B. at least if you see this article I wrote. you should not be too good B. I mentioned this article for Beginners :-)
11. female problems Er .. solve it by yourself @_@
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.