Learning lines and advice for beginners in PHP

Source: Internet
Author: User
Tags learn php php class php and mysql php framework zend zend framework

[Guide] This article is about the PHP learning problem, before the "heavy material!" A summary of PHP resources on GitHub, "in-depth discussion of PHP class encapsulation and inheritance," "PHP Learning Planning recommendations," and so on the PHP learning helpful content, in order to you can better learn PHP, this time mainly want to say a little bit of PHP learning line, At the end of this article, there are 10 tips for optimizing PHP performance.

This article is about PHP learning issues, before the "Heavyweight data!" A summary of PHP resources on GitHub, "in-depth discussion of PHP class encapsulation and inheritance," "PHP Learning Planning recommendations," and so on the PHP learning helpful content, in order to you can better learn PHP, this time mainly want to say a little bit of PHP learning line, At the end of this article, there are 10 tips for optimizing PHP performance.






We want to have a gradual learning process, here first to learn the process of PHP to summarize, this and a lot of learning PHP enthusiasts are the same:
(1) familiar with the basic elements of Html/css/js and other Web pages, the completion stage can be self-made simple web pages, the element attributes are relatively familiar.
(2) Understand the concept of dynamic language and operation mechanism, familiar with basic PHP syntax.
(3) Learn how to combine PHP with HTML to complete a simple dynamic page.
(4) Contact learning MySQL and start designing the database.
(5) Constantly consolidate PHP syntax, familiar with most common PHP functions, understand object-oriented programming, MySQL optimization, as well as some templates and frameworks.
(6) Finally complete a full-featured dynamic site.



Beginners do not see the above summary that PHP learning is very simple, programming is to need your serious thinking and continuous practice. Here is a detailed explanation of the PHP learning line. First of all, any site is composed of Web pages, that is, to complete a site, you must first learn to do Web pages, master static Web production technology is the prerequisite for learning to develop a website. So we have to learn HTML, for the future production site lay the foundation. Learning HTML should be learned while doing, any element of HTML to practice, only to understand what elements will play an effect, in order to deep memory, blindly reading is not.

Assuming you can already complete a static page, then you should start to understand the dynamic language, just a contact with dynamic language, many people may have a lot of confusion, the code is not as direct output, but to be processed, HTML is through the HTML parser, and PHP also through the PHP parser, Like learning HTML, for any parser to work, it must use its own syntax structure.

Learn PHP, you should feel lucky, because if you learn other languages, you will find that PHP is relatively simple,
At this stage, you have to understand the concept of HTML and PHP, you can now completely let PHP to you calculate one plus one equals a few, and then output in the browser. Don't be naïve, it's a small piece of code, but it's a big step toward your programming path. But now, you're still a rookie.

The next is to learn the database, MySQL can be said to be PHP's gold partner, we want to conquer this database, after you understand the concept of the database, you have to try to connect the database through PHP, and then use PHP successfully inserted, delete and update data.

At this point, you may be in this state: Do you have HTML? Yes, I can make up a few forms of the page of the row board! Do you know PHP? Will, I will write one plus one operation in the function, and then call! Do you have MySQL? Yes, I can insert the data in the database and delete it!

So what's the next thing to do? Try to make a small message book, this is also a novice facing a level. It took a while, you finally learned to insert the form data into the database, and then show it, it should be said that a program of the prototype has been born. However, you may look at people this forum, that development CMS, when can I write one? Do not worry, and then consolidate the knowledge, familiar with the essentials of PHP and MySQL development, and then look back at the message you wrote, you may suspect that it is really you write it? At this time, you can perfect the message book you wrote. The message should be added to the registration and paging function, if possible, the UI can also be enhanced.

Does that even have to be learned? No,no,no, it's early, you haven't touched oop yet? What about templates and frameworks? and continue to study! The PHP Framework provides a basic framework for building Web applications, simplifying the process of writing Web applications in PHP. Can save development time and help build more stable applications. So, the PHP framework is a tool that you can use to save time and strengthen your code. When you first choose the PHP framework, it is recommended to try a few more, each framework has its own strengths and weaknesses, such as the Zend Framework due to various functions, and has a broad support system, popular for a long time. CakePHP is a PHP framework later than Zend, and the corresponding support system is less, but more convenient and easy to use.

Once you understand the object-oriented and framework, you should touch the XML, in short, you will never find that you have all learned, learning! Learn something, never dream of a crash this said, more skills, but the lack of effort, it is useless. One thing you can guarantee is that you learn PHP, then learn other languages, definitely crash, and vice versa, if you have learned other languages before, then PHP must be fast.

It is absolutely beneficial to learn more about the code of others ' success, so it is the best way to look at the classic code that has been thoroughly tempered. In addition, to emphasize that, learning a technology may encounter difficulties, may be confused, you may have learned half of PHP, and began to play C # idea, or some people say that Java is very good, this time you must not waver, to persist in the end, thoroughly learned. I wish you success in PHP, develop your desired website.


Finally, share 10 PHP performance optimization tips to help you better with PHP development:

1. Foreach is more efficient, instead of using foreach as a while and for loop.

2. Inside the loop, do not declare variables, especially variables such as objects.

3. In multiple nested loops, if possible, the longest cycle should be placed in the inner layer, the shortest loop is placed in the outer layers, thereby reducing the number of times the CPU crosses the loop layer and optimizing program performance.

4. Use single quotes instead of double quotation marks to reference strings for PHP performance optimizations.

5. Replace i=i+1 with I+=1. In line with C + + habits, efficiency is high.

6. Optimize the Select SQL statement and make the INSERT and update operations as few as possible, to optimize the performance of PHP.

7. As little as possible to file operations, although PHP file operation efficiency is not low.

8. Use the PHP intrinsics as much as possible.

9. Do not use regular expressions in cases where you can manipulate functions with PHP internal strings.

10. Use file_get_contents instead of the file, fopen, feof, Fgets and other series of methods, as far as possible, because it is much more efficient.    But be aware of the PHP version of file_get_contents when opening a URL file. Original: http://www.php100.com/html/dujia/2015/0113/8306.html

Learning lines and suggestions for beginners in PHP

Related Article

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.