An interesting technical article PHP introduction

Source: Internet
Author: User
Tags array arrays code tag header php file php framework php introduction php source code

As a mid-level Phper rookie. Bored to love in the various PHP forums blindly turn. See a lot of PHP beginners have asked many of the same questions. And I have encountered it when I was learning PHP. Let PHP beginners take some detours. So suddenly a trance. Decided to write down this article. For PHP beginners only. If there is a mistake.
PHP is actually a very easy language to learn. If you want to master PHP for more than three years. A few years is enough. But why are we still rookie in three years?
Don't know what to start with. Learning PHP we have to learn the database. Learning the object oriented, learning the front end, learning about Linux, learning protocols and even art and so on directly led to the Phper are now the most tired of a programmer.
The most tired is nothing. Often PHP is considered an inferior program. Take the lowest level of salary. But to master almost all the knowledge of the Web. It is really unfair.
It is gratifying that we have gradually seen a change in the country. More and more companies from Java or C # to the PHP. So everyone phper must have their own dreams. You're all going to be great. B. Please believe it.
It's far away. Back to the point I'm talking about. The following questions contain the problems I have encountered. Maybe I'm not right or you don't agree with me. I'm very willing to accept your opinion. Anyway, we just want phper to be:-).
1. The problem of coding
This is not just PHP. As long as it's on the program. At least I've met the people around me. And on the web side. Often coding problems are very difficult to solve. It's very difficult to debug. Sometimes the program is out of the question, it's hard to think of coding problems, and so on.
These questions always haunt us. So I suggest a beginner of PHP. Be sure to encode a uniform. And it is strongly recommended that the unification be UTF-8. The use of GBK or GB2312 is not recommended in Chinese. Because it is not recognized in the AJAX transmission.
If you want to unify your code, be aware of any place where the code may appear.

1) Header Code
Personal advice should add the following sentence in your PHP (except for special headers)
Copy CodeThe code is as follows:
Header ("Content-type:text/html;charset=utf-8");

This avoids some of the problems. For example, we can see that some sites submit an alert and then jump. But they did not set the code. If his code doesn't match the browser's default encoding, it will appear garbled.
You are simply HTML. Be sure to put the meta code tag in front of the title tag. If you don't understand, remember to put the coded information on the first line of the head tag. The ultimate effect is this
Copy CodeThe code is as follows:
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
...

2 Encoding of files
When we save the file, we must choose the code to be unified. If you follow the above, we should choose UTF-8.
Generic editors have encoded information for this file. If you find that it is not UTF-8, please change it immediately.
For example, we opened a template file in Dreamweaver. Found in the lower-right corner of the GB2312 (Simplified Chinese). Do not make any changes at this time. Immediately ctrl+j and then select the encoding to change to UTF-8 mode and save.
The encoding of the file is not necessarily a PHP file. You also have to make sure that your JavaScript files and CSS files are UTF-8 encoded.
There is another important point. is the BOM. This dongdong PHP is not very welcome. So we have to choose UTF-8 without the BOM format when we save it. If the editor you are using is UE. Then please pay attention to this point.
3 The encoding of the database
I don't want to talk about it. There are too many articles on the Internet. If you are MySQL remember to set NAMES = ' utf8′ on each connection. And there is no horizontal line in the middle of that utf8.
2.MVC problem
The programmer should be a perfectionist in theory. They're not just trying to write the program, it's going to work. and elegant.
But then again. Will our code be elegant after the program has been done according to MVC? The answer is, of course, negative.
Learning a framework is a process of understanding. When you truly appreciate the benefits of this architecture, you will understand its true meaning. Don't be blind.
Sometimes we do that. Use this month's time to learn about MVC. Well, I think you should do it. You learn to set goals for yourself.
But after one months, we may not really understand MVC. But at least we will be based on his model of his basic. In other words, we may not have learned the Sunflower Sutra. But we should be able to use the evil sword.
3. Object-oriented issues
About the object-oriented problem with PHP. It's been a long time. Some people don't think that PHP is a good thing to object to. Some people don't even think object oriented is a good thing, like Linus.
We don't have to dwell on this thing. At least we should know from object-oriented to the present. After so many years of evolution. Apply to various projects and even languages. We have reason to believe that existence is justified.
Practice is the only criterion for testing truth. So many years of object-oriented development situation better. It seems that we have to learn to become a must.
Similar to the knowledge of some architectures. Object-oriented is not so studious. Object oriented is a kind of idea. But when it comes to a particular language, there are some subtle changes in its meaning.
PHP's object-oriented is flexible. Plus its unique magic method. It will create a special situation of object-oriented. Maybe it's not the same as the Object-oriented object you normally see in Java.
You don't have to put the method you need into a class that is object-oriented. When you really realize that object-oriented coding is fast for your code, it brings convenience. You have a deeper understanding of object-oriented.
It is the so-called haste to waste. Don't be impatient. You want to understand the theory of relativity within a few days. That's sheer nonsense.
4. The problem of algorithm
It seems that PHP is always very far away from the algorithm. Most of the PHP algorithms are based on arrays. And we know that the properties of PHP's arrays are doomed when the array becomes very large. Efficiency will plummet.
In fact, PHP is a website to do. We don't have to bring her any high hats. There are very few places in the web, especially in the context of the front-end that PHP serves, that will involve algorithms.
PHP algorithm surface test is nothing more than the array or the operation of the string. The brain and the manual. That's basically fine.
Then you may ask. I want to learn PHP. So, do I still learn algorithms?
I think you need to learn. And more need to learn data structures. This course is like an internal strength. Will influence your coding imperceptibly.
At this time again with our front of the evil sword. Congratulations, you've learned the Sunflower Sutra!
5. The question of the framework
PHP's framework is the largest of all languages. Use no frame. What frame is it? This has become a controversial topic.
My advice is to recommend learning at least one frame. This will deepen your understanding of PHP. Our learning framework is not about how to use this framework. How to do the project.
We're going to look at its source code. See how he does it. At this point you can choose to develop a small frame of your own. Do not ask how many projects to use.
We just want to learn.
6.JavaScript problem
I can say that I have seen so many languages. The most amazing thing is the JavaScript. In peacetime, Java has always declared itself to be the object. In fact, I think that JavaScript is all the object.
Does JavaScript learn? Learn! In fact, in peacetime web use time. The typical JavaScript operation is DOM operations.
is JavaScript hard to learn? It's hard to learn! If we are bound by the object-oriented thinking of other languages. It's hard to understand the object-oriented aspects of JavaScript. And JavaScript has a lot of concepts.
Prototype arguments call apply callee caller closures and other concepts let us at a loss. Coupled with the bizarre JavaScript code style and its difficult to debug features directly led to our rookie to avoid the distance.
Once I forwarded a piece of code to implement Document.ready. Its uncanny degree had to admire.
I think the source of some JavaScript framework is the best way to learn. I used to write my PHP framework. Because of the use of a unified portal + your own defined URL rules. So when you use a form with a normal property for GET, you can't obtain parameters.
This is when I think of the Formserialize method in Jquery.form. Pick it up and make some changes. You can use it.
7.CSS problem
What I'm doing is separating CSS from JavaScript. I think CSS learning is more characteristic.
In fact, I would say that CSS is the simplest thing. We just know some basic CSS properties. Writing a page is absolutely not a problem.
The main feature of CSS is that you have to do it. You read the book n css rather than actually write a page.
Another feature of CSS is that you have to try more. Maybe this property doesn't work for you. That's the dumbest and most effective way to:-).
Of course, this is just the requirements of the primary CSS. After that, we'll have to be compatible with browsers. In fact, this is not difficult nothing more than a few browsers open a property at the same time a test.
can also memorize some hack such as IE6 know IE all know * and so on. If you think it's not standard to write CSS like this. Then put the hack in a different CSS file. Like IE6, it's called Ie6.css.
Then you can use the following code on the page.
Copy CodeThe code is as follows:
<!--[If Lt IE 6]>
<link href= "Css/ie6.css" rel= "stylesheet" type= "Text/css"/>
<! [endif]-->

The more advanced of course is the user's experience and design. I don't know about that. @_@ hope Talent added.
8.linux problem
It is highly recommended that a Linux system be installed on each computer. If you think it's too much to toss, you can choose Wubi to install Ubuntu. This is the simplest and most effective way to lazy people.
When you are bored you can download a copy of the PHP source code to try it. Avoid apt-get. Because often the server version is not Rhel is CentOS. There is no such command.
And Apt-get is often not the latest version, and can not be customized.
Linux will always have such a puzzling problem of living. For example, the environment is a little different from compiling. The service does not start.
Don't worry about it at this time. Look at the error prompted to see the log. Google itself to try to solve.
Finish compiling don't feel like it's over. Try different configurations. and revise the source code again to try to compile.
For example, we downloaded a copy of Nginx's source code. And then modify the header first in some places. You can compile an HTTP WEB server of your own.
Of course, if you call BWS or GWS, you can:-).
There's a problem. Does Linux need to be back on command? This is understandable. Memorize some commonly used commands to improve speed. I need to reflect on that. Often some common commands also need to look at the parameters.
The other one is the shell problem. The shell is not difficult, but the syntax looks ugly to me @_@. Look at the wiki and you'll learn half of it. The main is to contact. We can see a phenomenon. Some companies are also listed as mandatory when recruiting senior Phper.
In fact, the information on the Internet Linux is very much. Most of the problems you encounter will be met by others. So good at Google. and read English well.
9. Language problems
This problem is too much of a battle. Ultimately, no one has defeated anyone. We don't have to get involved in these boring things. These are all young manure to do.
Do you have a linus of cow B? He sprayed C + + for so many years. How's C + +?
So we don't have to dwell on this. Do what you have to do to be OK.
Now that you've chosen PHP, don't hesitate.
Maybe PHP doesn't look good enough for us to do the project. Then we can use Java or C as a middleware.
A language to play her greatest and most use is the truth.
10. The problem of attitude
Attitude must be modest and prudent. This is the virtue that a programmer should have. Don't inflate yourself.
The more you learn, the more you will find yourself deficient.
You can say some arrogant things when you wait for your cow B. But now we're not cattle b. At least if you see this article I wrote. You're not too much of a B. I said this article is for beginners:-)
11. Women's problems
Uh.. Do it yourself, @_@.



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.