> ## 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 Exponentiation Assignment

The `**=` operator is the exponentiation assignment operator in PHP. It raises the variable on the left operand to the power of the evaluated expression on the right operand, and subsequently assigns the computed result back to the left-side variable.

```php theme={"dark"}
$a **= $b;
```

This operation is semantically equivalent to the expanded assignment syntax:

```php theme={"dark"}
$a = $a ** $b;
```

## Technical Mechanics

**Type Coercion and Resolution**
Before execution, PHP evaluates the right-hand expression. In PHP 8.0 and later, applying arithmetic operators to incompatible types (such as arrays, objects, or non-numeric strings) throws a `TypeError`. For valid numeric strings, PHP implicitly casts them to an `int` or `float`.

The expression evaluates to, and the left operand is assigned, a specific data type based on the operands and the mathematical result:

* **`int`**: Evaluates to an integer if both operands are integers, the right operand (exponent) is greater than or equal to zero, and the computed value does not exceed `PHP_INT_MAX` or fall below `PHP_INT_MIN`.
* **`float`**: Evaluates to a float if either operand is a float, if an integer base is raised to a negative integer exponent (which produces a fraction), or if the resulting integer overflows or underflows the system's integer bounds (`PHP_INT_MAX` and `PHP_INT_MIN`).
* **`float` (`NAN`)**: Evaluates to `NAN` (Not a Number) if a negative base is raised to a fractional exponent.

**Precedence and Associativity**
As an assignment operator, `**=` has very low precedence. Consequently, the entire expression on the right-hand side is fully evaluated before the exponentiation and assignment operations are performed.

Like all assignment operators in PHP, `**=` is right-associative. In chained assignments, the right-most operations are evaluated first. For example, the expression `$a **= $b **= $c` is evaluated as `$a **= ($b **= $c)`.

## Syntax Visualization

```php theme={"dark"}
// Standard integer exponentiation
$base = 2;
$base **= 3; 
// $base is now 8 (type: int)

// Float resolution via negative integer exponent
$base = 2;
$base **= -1; 
// $base is now 0.5 (type: float)

// Float resolution via fractional exponent
$base = 9;
$base **= 0.5; 
// $base is now 3.0 (type: float)

// Right-hand expression precedence
$base = 2;
$base **= 2 + 1; 
// Evaluates as $base **= 3. $base is now 8 (type: int).

// Right-associativity in chained assignments
$a = 2;
$b = 3;
$a **= $b **= 2; 
// Evaluates $b **= 2 first ($b becomes 9). 
// Then evaluates $a **= 9 ($a becomes 512).

// Negative base with fractional exponent
$base = -1;
$base **= 0.5; 
// $base is now NAN (type: float)
```

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