• Translate

12/21/2015

9 Things Not To Do In PHP 7

Tutorial PHP |

Advertisement

9 Things Not To Do In PHP 7 | PHP 7 some time ago has been officially launched, PHP lovers certainly welcome it with joy. PHP 7 appears without PHP 6, so the direct jump from 5 to 7. There are some changes in PHP 7, there are some features removed and some were added.

9 Things You Should Not Do In PHP 7

Here are 9 things you should not do in PHP 7, although in fact this is not just a matter of PHP 7, but can be common in PHP programming, at least for the quality of the code that you create can be better than in previous years, let's make a change PHP to 7 as momentum to make a better PHP code.
  • Do Not Use mysql_ Functions
    Already since PHP 5.x you are advised to no longer use mysql_ function. PHP 7 removes this function from its core and for that you need to move to the function mysqli_ as much better, or use the PDO to be more flexible.
  • Do Not Be Too Extravagant Writing Code
    Coding you make determines the access speed of your site, about speed also becomes important in PHP 7. Do not just be satisfied with the speed of your site just because it has been switched to PHP 7.

    To understand the importance of speed and what you can do to make it better, you can re-read the basic guidelines of PHP.

    As a developer you should make sure to create a script that is only really needed it, combine them if possible to be more frugal, write database queries more efficiently, use caching when possible, and so forth.
  • Do Not Use PHP Closing Tag At The End Of A File
    If you notice, most of the core files of WordPress eliminate PHP closing tag at the end of each file. In fact, Zend Framework specifically prohibits it. It is not required by PHP, and by eliminating it at the end of your file to make sure that there are no spaces are added.
  • Do Not Perform Queries In A Loop
    Perform database queries in a LOPP is a waste. This will provide an unnecessary burden on the system that you created, and of course it would be better if it is done outside the loop. 
  • Do Not Use * In sql Query
    Reduce use * in SQL queries, especially if you have a database that has a lot of columns in the table. Should specify which columns are going to take, this will minimize resource usage.
    • Do Not Easily Believe What On User Input
      Somewhat less wise to believe what a programmer to be inputted by the user application without giving various rules. Make sure you always do a filter, sanitize, escape, check and use fallbacks to obtain definitive data input.
    • Never Feel Smart
      You may be able to speed up the load time 0:01 seconds for each page, since your goal is to write code that is elegant and it is a good intention, you may use a wide variety of logic to do that to other people and even your own headache thinking about it.

      But actually a simple thing to do is simply write your variable names correctly, documenting code that you create, make it all the more brief but clear. There is also a good idea to use a standard object-oriented, where you write better documentation without having a lot of inline comment.
    • Do Not Ignore Applications Help
      PHP has been used for quite a long time, while the website is much longer than that. The changes you make may also have been done by someone else before. Do not be afraid to use the help of others, GitHub can be your best friend, Composer, Packagist can also be your best friend.

      In addition there are a variety of tools to manipulate the color of the profiler to unit testing framework, on the MailChimp API to bootstrap, all available for free.
    • Do Not Overlook Other Programming Languages
      If you’re a PHP person it is now standard practice to know about HTML, CSS, Javascript and MySQL at least. When you have a pretty good handle on these languages it’s time to learn Javascript again. Javascript is not jQuery. You should learn Javascript properly to be able to utilize it efficiently.

      I would also recommend learning all about object oriented PHP, it is a life-saver and will make your code better by orders of magnitude. It will also open doors to languages like C# and Java, they will be a lot easier to understand with OOP under your belt.

      Broaden your knowledge by learning about package managers, build scripts, Coffeescript, LESS, SASS, YAML, templating engines and other awesome tools. I would heartily recommend looking at other frameworks, Laravel in particular.

      When you’re doing pretty well with these, what about Ruby, Ruby on Rails, app development for Android, iPhone, Windows Phone? You’d think that there is no point because these fall outside your comfort zone and work needs, but that’s just the point. Each language has something useful to teach and a little extra knowledge never hurts. It’s not an accident that all top PHP developers know a lot about other programming languages!

    Disclaimer: Images, Content of articles or videos that exist on the web sometimes come from various sources of other media. Copyright is fully owned by the source. If there is a problem with this matter, you can contact us here.
    How to style text in Disqus comments:
    • To write a bold letter please use <strong></strong> or <b></b>.
    • To write a italic letter please use <em></em> or <i></i>.
    • To write a underline letter please use <u></u>.
    • To write a strikethrought letter please use <strike></strike>.
    • To write HTML code, please use <code></code> or <pre></pre> or <pre><code></code></pre>, and please parse the code in the parser box below.
    Show Parser Box