PHP types
Guilty Of PHP articles about PHP types
6 articles
-
Read PHP Scalars in serialize() Output and Check Array and Object Round Trips
Recognize integer and string markers, then use round-trip checks to verify array entries and object state without relying on printed output alone.
-
Restrict Object Classes When Calling PHP unserialize()
Pass an allowed_classes list or false, then check whether the restored value is the expected object or __PHP_Incomplete_Class before using it.
-
Define a PHP Function That Takes Arguments and Returns a Value
Build a reusable line-total calculation, then follow two calls from their supplied numbers through the function and back to the caller.
-
Declare a Readonly PHP Class Without Invalid Properties
Use a typed data holder to check declarations, inheritance, traits and writes before converting an existing class.
-
Pass a One-Off PHP Object to a Function That Expects an Interface
Create an anonymous Formatter directly in a function call, pass it constructor arguments, and extend a base class when it needs a protected helper.
-
Tell Numbers from Strings When Assigning PHP Variables
Assign whole-number, decimal and quoted-digit values, then use var_dump() to inspect them and compare one variable before and after reassignment.
