Skip to main content

8 Things not to do in Php 7:

Here are thing which you should not do in PHP7. this things are not just matter of php7 some of this can be common in Programing languages, at least for quality code and improve performance.


1) Avoid writing Wasteful Code
This simply means do not write useless code which will waste your performance. In fact php7 increase speed so much that it could be hide some of problems. As a developer, you should always make sure that your application only load scripts when it is require and concatenate them when it's possible. Write database queries, use caching when possible, and so on...

2) Verify User Input
Always filter, sanitize, escape, check and use fallbacks.
Make sure to use built in functions like filter_var() to check for proper values and escaping and other functions when working with databases.

3) Do Not Use PHP Close Tags At The End Of A file
If you noticed most php CMS and Framework files omit the ending PHP tag when a file ends with PHP code. The Zend Framework specifically forbids that it is not required by PHP.
By omitting PHP close tags at the end of a file you are making sure that no trailing whitespace can be added.

4) Do Not Perform Queries In A Loop
Performing database queries in a loop is time taking and wasteful process. You achieve the same result faster with 1 or 2 queries or by creating a sub query outside of loop. If you had a situation where this would be needed just create diff queries according to your requirement and create an array of data then simply loop over data.

5) Do Not Use mysql_ Functions
PHP 7 will remove mysql_* function has been removed. That means you’ll need to move to the far better mysqli_ functions, or the even more flexible PDO or an ORM.

6) Avoid Pass By Reference If Not Needed
In some cases passing by reference is useful and necessary, but on many other occasions this just makes the code more difficult to understand and try to predict the result.
Apparently, some people think that Pass By Reference makes their code faster, which according to this reference (link) (in English), is not true.
An example of why referrals are bad in PHP is with respect to the built in shuffle () or sort () functions.
Instead of returning the randomized or sorted array, the functions modify the original variable, which is completely illogical to my mind.

7) Stop using * in SQL queries
It seems like MySQL database issue, but we write SQL queries in our PHP code so I think it’s worth it. Avoid using wildcard characters (*) in n SQL queries, especially when your tables have many columns. Use only those columns which you need that helps to decrease the use of system resources, makes things clearer and protects your data.

8) Do Not Reinvent the Code
PHP has been around for a long while now; websites have been made for even longer.
It is possible that anything you want to do, someone else has done before.

Do not be afraid to ask from your friends Github , Composer and Packagist.

Comments

Popular posts from this blog

Why Prestashop is the best eCommerce platform?

Why Prestashop is the best eCommerce  platform? E-commerce is the current buzzword in the online world. Every business owner desires to have online eCommerce website to reach many people and get more sales. Prestashop is the one of the best eCommerce solution for the best eCommerce site because of its feature. Free, Open-source Prestashop is totally free to download, You don't need to pay for using it. Supports whenever you need them. Best part of this is you don't need to search for the required documentation as these are available on the website of Prestashop. Easy to Install  And Smart Back-End Prestashop scores very high in the segment of usability. The installation is very easy and the installation requires very little technical skills. PrestaShop helps you to run your store in a manner that proves beneficial for you. It is highly impressive and it is even integrated with all the major carriers such as UPS, FedEx and USPS. Also, the backend dashboard o...

10 Digital Marketing Tips for Small Business Owners

Online Marketing is plays an important role for any small business hoping to stay competitive . But what online marketing tactics should you focus on in your limited time is a busy entrepreneur? Here are 10 necessary digital marketing tips for all small business owners. 1. Starts with Your Website Make sure you have an updated, responsive and attractive website that is easy for users to negative across all devices and has a modern and clean design wit not more than two or three colour theme. 2. Don’t Forget the Basics Include necessary information customers want to know- your business address, phone number, E-mail address, hours of operations, etc. - on your website where visitors can find them right away. You’d be surprised how many businesses forget to list this info. 3. Think Local If your business targets local customers, claim your listings on local search directories, such as Google My Business and Bing places for business. They are free and help ensure th...

Latest PHP web development trends

1) Faster and leaner PHP 7 - PHP 7 looks familiar for developers, but it is especially focused on high performance. - Experts predict the growth of PHP 7 adoption rate, and they have several reasons for verifying such forecast.  - Using PHP 7 the performance of applications has gained up twice comparing with older versions.  - RAM consumption was decreased by 50% during the request processing in PHP 7. - Previously there are many errors which are reason of application stop working now those can be processed as exceptions - The most popular CMS and frameworks such as WordPress, Magento and Symfony ready for PHP 7. - All these changes of PHP 7 increase application speed and reduce resources needs. 2) Market forecast - Experts predict that by 2025 half of American enterprises are expected to run more than 10 applications. - Though PHP cannot be the best choice for any web solutions, it is still holding the lead positions in the development of tech startups...