{"id":545,"date":"2016-03-04T08:58:08","date_gmt":"2016-03-04T08:58:08","guid":{"rendered":"http:\/\/www.octalsoftware.co.uk\/blog\/?p=545"},"modified":"2017-02-16T13:18:43","modified_gmt":"2017-02-16T13:18:43","slug":"10-things-to-be-avoided-in-php7","status":"publish","type":"post","link":"https:\/\/www.octalsoftware.co.uk\/blog\/10-things-to-be-avoided-in-php7\/","title":{"rendered":"10 Things to Be Avoided in PHP7"},"content":{"rendered":"<p><span style=\"font-size: medium;\">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 <a href=\"https:\/\/www.octalsoftware.co.uk\/web-technology\/php-development\" target=\"_blank\">PHP Development<\/a> 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.<\/span><\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: medium;\">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\u2019s our advice to take care of the following 10 things to avoid unnecessary trouble;<\/span><\/p>\n<ol>\n<li><span style=\"font-size: medium;\"><b>mysql_functions Should Not Be Used<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">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. <\/span><\/p>\n<ol start=\"2\">\n<li><span style=\"font-size: medium;\"><b>Wasteful Codes Are Not to Be Written<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">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. <\/span><\/p>\n<ol start=\"3\">\n<li><span style=\"font-size: medium;\"><b>Never Use PHP Close Tags At the End of A File<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">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. <\/span><\/p>\n<ol start=\"4\">\n<li><span style=\"font-size: medium;\"><b>Never Pass By Reference If Not Required<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">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. <\/span><\/p>\n<ol start=\"5\">\n<li><span style=\"font-size: medium;\"><b>Never Perform Queries in A Loop<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">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. <\/span><\/p>\n<ol start=\"6\">\n<li><span style=\"font-size: medium;\"><b>*In SQL Queries Should Not Be Used<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">In any case, wildcards in SQL queries should not be used, especially when you have a database with a lot of columns. <\/span><\/p>\n<ol start=\"7\">\n<li><span style=\"font-size: medium;\"><b>Never Trust User Input<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">Rather than depending on users\u2019 input, you must always filter, sterilize, getaway, check and use fallbacks. <\/span><\/p>\n<ol start=\"8\">\n<li><span style=\"font-size: medium;\"><b>Do Not Mess Around <\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">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. <\/span><\/p>\n<ol start=\"9\">\n<li><span style=\"font-size: medium;\"><b>Do Not Try to Reinvent Things<\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">Do not reinvent the wheel as everything including color manipulation tools, profile, unit testing frameworks etc is available just at the push of button. <\/span><\/p>\n<ol start=\"10\">\n<li><span style=\"font-size: medium;\"><b>Respect Other Language <\/b><\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: medium;\">Being a PHP developer, you should not also neglect other languages like HTML, CSS, Javascript and MySQL. Boost your knowledge by learning build scripts, package etc.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":546,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-545","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"aioseo_notices":[],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/posts\/545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=545"}],"version-history":[{"count":3,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/posts\/545\/revisions"}],"predecessor-version":[{"id":689,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/posts\/545\/revisions\/689"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/media\/546"}],"wp:attachment":[{"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.octalsoftware.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}