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

# PHP true

In PHP, `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

The `true` 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.

```php theme={"dark"}
$a = true;  // Standard (PSR-12 compliant)
$b = TRUE;  // Valid, but non-standard
$c = True;  // Valid, but non-standard

var_dump($a === $b); // bool(true)
```

## Type Coercion and Casting

When PHP's Zend Engine coerces or explicitly casts the `true` 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_dump` outputs whole-number floats without the `.0` decimal).
* **String:** Casts to `"1"` (Note: `false` casts to an empty string `""`).
* **Array:** Casts to an indexed array containing the boolean as its single element at index `0`.

```php theme={"dark"}
var_dump((int) true);    // int(1)
var_dump((float) true);  // float(1)
var_dump((string) true); // string(1) "1"
var_dump((array) true);  // array(1) { [0]=> bool(true) }
```

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

```php theme={"dark"}
// Loose comparison (Type juggling occurs)
var_dump(true == 1);       // bool(true)
var_dump(true == "1");     // bool(true)
var_dump(true == "hello"); // bool(true)
var_dump(true == "0");     // bool(false)

// Strict comparison (Type and value must match)
var_dump(true === 1);       // bool(false)
var_dump(true === true);    // bool(true)
```

## Type Verification

To programmatically verify if a variable holds the exact boolean `true` 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`.

```php theme={"dark"}
$value = true;

var_dump(is_bool($value));         // bool(true) - Only confirms type (could be false)
var_dump($value === true);         // bool(true) - Confirms both type and state
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor PHP Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
