Subscribe to our email newsletter » Subscribe to our email newsletter to receive updates » Free chat room  |   Star on GitHub

PHP Strict Types

PHP gets enough flack for being insecure and untamed. Moving toward stronger security and stricter coding is one of the benefits of PHP 7+

The short answer is you should pretty much always use strict_types whenever possible, these days. However, if you’re upgrading old code, you of course need to be sure that everything works correctly after adding strict_types, because the PHP engine will interpret it more strictly.

It is also worth nothing that current implementation is not very aggressive, so you can still include PHP files (etc) in other files, and it will not necessarily break them if their code does not follow same type suit.

And yes, you have to declare it at the top of every single script 🙂

Ref: https://stackoverflow.com/questions/48723637/what-does-strict-types-do-in-php
Ref: https://stackoverflow.com/questions/37111470/enabling-strict-types-globally-in-php-7
Ref: https://github.com/Automattic/phpcs-neutron-standard/issues/20
Ref: https://www.quora.com/Are-strict_types-in-PHP-7-not-a-bad-idea

Recent Blog Posts

The Last (Lightweight) CSS Reset You’ll Need

CSS resets have always been a pain in the neck, because of new elements and CSS options being released every few years. To make it more annoying, various browsers have decided to come up with their own default CSS settings in case they are undefined (and sometimes, even if they are defined). Since our team […]

Custom Cron Jobs (Unrestricted Code) Are Here

One of the most requested features ever, custom cron jobs, is finally here! A lot of developers who have come across SlickStack always say “this is awesome and super optimized but I still need the ability to add a few custom cron jobs” for a special API to import their WooCommerce products, or a third […]

Fastest WordPress Hosting (For Under $5/mo)

For over a decade, WordPress has continued to dominate the web hosting industry as small businesses and bloggers alike continue to seek out free and reliable CMS software that can easily be moved between web servers as needed, without being locked-in to any single platform or service. But in the past few years especially, high-tech […]