> ## 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 Left Shift

The `<<` operator in PHP is the bitwise left shift operator. It shifts the binary representation of the left operand to the left by the number of bit positions specified by the right operand.

```php theme={"dark"}
$result = $value << $positions;
```

## Mechanics

When the `<<` operator is evaluated, PHP performs the following sequence at the bit level:

1. **Integer Casting:** Both operands are evaluated and implicitly cast to integers. Floating-point values are truncated.
2. **Bit Shifting:** The bits of `$value` are moved to the left by the exact number of steps defined by `$positions`.
3. **Zero Extension:** The vacated bit positions on the least significant side (the right) are filled with zeros.
4. **Truncation:** Any bits shifted beyond the system's maximum integer bit width (the Most Significant Bit) are discarded.

Mathematically, shifting left by `$positions` is equivalent to multiplying the left operand by 2 raised to the power of the right operand: `$value * (2 ** $positions)`.

## Syntax Visualization

```php theme={"dark"}
$a = 5;         // Binary: 00000101
$b = $a << 2;   // Binary: 00010100 (Decimal: 20)

// Mathematical equivalent: 5 * (2^2) = 20
```

## Technical Characteristics

* **Signed Integers:** PHP only supports signed integers (typically 64-bit on modern systems) using two's complement representation. If a left shift pushes a `1` into the Most Significant Bit (MSB), the resulting integer will become negative.
* **Negative Shift Bounds:** Attempting to shift by a negative number of positions (e.g., `$a << -1`) is invalid and will throw an `ArithmeticError` in PHP.
* **Overshifting:** Shifting by a number of positions greater than or equal to the bit width of an integer on the host system (e.g., 64 on a 64-bit architecture) results in `0`.

## Bit-Level Execution Example

```php theme={"dark"}
$value = 14;      // Binary: 00000000 00000000 00000000 00001110
$shift = $value << 3; 

// 1. Shift bits left by 3 spaces
// 2. Pad the 3 rightmost spaces with 0s
// Result:           00000000 00000000 00000000 01110000 (Decimal: 112)
```

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