> ## 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 Greater Than

The `>` (greater than) operator is a binary relational operator that evaluates whether the value of its left operand is strictly larger than the value of its right operand. It returns a boolean `true` if the condition is met, and `false` otherwise.

```php theme={"dark"}
$result = $expression1 > $expression2;
```

Because PHP is a dynamically typed language, the `>` operator utilizes internal type juggling (coercion) when evaluating operands of differing data types. The Zend Engine applies specific comparison rules based on the types involved:

* **Numeric vs. Numeric (Integer/Float):** Performs a standard mathematical comparison.
* **String vs. String:** If *both* strings are well-formed numeric strings, PHP casts them to numbers and performs a mathematical comparison. Otherwise, it performs a lexicographical (alphabetical) comparison based on the underlying byte (ASCII) values of the characters.
* **Numeric vs. String:**
  * *PHP 8.0 and later:* If the string contains a well-formed numeric value, it is cast to a number for mathematical comparison. If the string is non-numeric, the number is cast to a string, and a lexicographical comparison is performed.
  * *Prior to PHP 8.0:* The string is aggressively cast to a number (often evaluating to `0` if non-numeric) before comparison.
* **Boolean vs. Any Type:** The non-boolean operand is cast to a boolean before comparison. In PHP, `false` is considered less than `true`.
* **Array vs. Array:** Evaluates the count of elements. An array with more elements is considered greater. If the counts are identical, PHP recursively compares the values of the elements key by key.

## Syntax and Evaluation Examples

```php theme={"dark"}
// Standard numeric comparison
var_dump(10 > 5);        // bool(true)
var_dump(5 > 5);         // bool(false) - strict inequality required

// String comparison (Numeric strings vs. Lexicographical)
var_dump("10" > "2");    // bool(true) - Both are numeric strings, compared mathematically as 10 > 2
var_dump("z" > "a");     // bool(true) - Lexicographical: ASCII 122 > ASCII 97
var_dump("10a" > "2b");  // bool(false) - Non-numeric strings, lexicographical: '1' (49) is not > '2' (50)

// Cross-type coercion (PHP 8.0+ behavior)
var_dump(42 > "20");     // bool(true) - "20" is cast to integer 20
var_dump(42 > "foo");    // bool(false) - 42 cast to "42", lexicographical comparison fails

// Boolean coercion
var_dump(true > false);  // bool(true) - true is greater than false
var_dump(5 > true);      // bool(false) - 5 is cast to true, evaluates as true > true
```

## Operator Precedence and Associativity

The `>` operator has **non-associative** directionality. It sits lower in the precedence table than arithmetic operators (`+`, `-`, `*`, `/`) but higher than logical operators (`&&`, `||`) and assignment operators (`=`).

Because it is non-associative, chaining the operator without explicit grouping parentheses results in a parse error.

```php theme={"dark"}
// Valid: Arithmetic evaluates before the relational operator
$result = 5 + 5 > 8;     // Evaluates as (5 + 5) > 8 -> bool(true)

// Invalid: Non-associative chaining throws a ParseError
$result = 10 > 5 > 2;    // Parse error: syntax error, unexpected token ">"

// Valid: Explicit grouping resolves associativity
$result = (10 > 5) > 2;  // Evaluates as true > 2. 
                         // 2 is cast to boolean true. 
                         // Evaluates as true > true -> bool(false)
```

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