In PHP,Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
true is a reserved keyword and a boolean literal representing the affirmative truth state in boolean logic. It is one of the two possible states of the scalar bool data type, the other being false.
Syntax and Case Sensitivity
Thetrue literal is case-insensitive. However, the PHP-FIG PSR-12 coding standard mandates the use of strictly lowercase letters for all reserved keywords, including boolean literals.
Type Coercion and Casting
When PHP’s Zend Engine coerces or explicitly casts thetrue literal into other scalar or compound types, it follows strict internal conversion rules:
- Integer: Casts to
1. - Float: Casts to a floating-point
1.0(Note:var_dumpoutputs whole-number floats without the.0decimal). - String: Casts to
"1"(Note:falsecasts to an empty string""). - Array: Casts to an indexed array containing the boolean as its single element at index
0.
Comparison Mechanics
Because PHP is a dynamically typed language,true behaves differently depending on whether an equality (==) or identity (===) operator is used.
Under loose comparison (==), PHP performs type juggling, coercing operands to booleans. Specific “falsy” values—such as 0, 0.0, "0", "", null, and empty arrays []—evaluate to false, while most other values evaluate to true. Under strict comparison (===), no type coercion occurs; the operand must be of type bool and hold the exact value of true.
Type Verification
To programmatically verify if a variable holds the exact booleantrue state, strict comparison (===) is required. Relying solely on type-checking functions like is_bool() is insufficient, as it only verifies the data type and will return true even if the variable holds false.
Master PHP with Deep Grasping Methodology!Learn More





