PHP7 is the latest version and a revolution, which is going to change the entire function of delivering applications that power everything from websites and mobile to enterprises and the cloud. This is the most significant change for PHP Development since PHP 5 got released in 2004, fetching huge performance improvements, explosively reduced memory consumption, and a host of brand-new language features to have your apps touch new heights.
However, it is notable that PHP 7 appeared after skipping PHP 6; therefore, you see some features are removed and a few more things are added. Hence, it’s our advice to take care of the following 10 things to avoid unnecessary trouble;
- mysql_functions Should Not Be Used
It is high time when you are advised to put an end to the use of mysql_functions. It will be removed from core by PHP7 altogether which means you will have to switch to the way superior mysqli_functions, or will adopt the even more flexible PDO implementation.
- Wasteful Codes Are Not to Be Written
Many of you may find it surprising, however, it is of equal significance as the speed gets a boost in PHP 7; therefore, a few of your issues are hidden. Never get satisfied with the speed of your site as the shift to PHP7 has made it quicker. As a developer, ensure to load scripts when required, associate them when needed, write effective database queries, using cache when it is necessary etc.
- Never Use PHP Close Tags At the End of A File
If you observe closely, most core WordPress files omit the ending PHP tag when a file ends with PHP code. As a matter of fact, the ZEND framework forbids it in particular. It is not needed by PHP and by skipping it at the end of a file you are ensuring that no trailing whitespace can be included.
- Never Pass By Reference If Not Required
Passing by references is something that should not be practiced. It can be understood that in some cases it is useful, but it makes code harder to understand and follow in many other. It is especially very tough to forecast the result.
- Never Perform Queries in A Loop
Getting database queries performed in a loop is simply useless. Unnecessary stress on your system is kept and it is quite probable that same results are achieved quicker outside the loop.
- *In SQL Queries Should Not Be Used
In any case, wildcards in SQL queries should not be used, especially when you have a database with a lot of columns.
- Never Trust User Input
Rather than depending on users’ input, you must always filter, sterilize, getaway, check and use fallbacks.
- Do Not Mess Around
Prepare a list of your variables properly, document your code and pick clarity over brevity. You can rather use standardized object oriented code to document it.
- Do Not Try to Reinvent Things
Do not reinvent the wheel as everything including color manipulation tools, profile, unit testing frameworks etc is available just at the push of button.
- Respect Other Language