NEW! Subscribe to our email newsletter » 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

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...

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...

MailChimp Banned Over Censorship Concerns

Starting immediately, SlickStack has begun warning WordPress sites that have MailChimp software installed that we will begin banning it by default at some point in the near future (Note: users are always free to install their own plugin blacklisttxt file, instead of...