> ## 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 Positional Parameter

Positional parameters represent the default argument-passing mechanism in PHP, where arguments provided during a function or method invocation are bound to the corresponding parameters in the function signature strictly based on their sequential order. The PHP engine resolves the mapping by matching the index of the passed argument to the index of the defined parameter.

## Syntax and Binding Mechanics

When a function is invoked, the first argument evaluates and binds to the first parameter, the second argument to the second parameter, and so forth.

```php theme={"dark"}
function assignValues($a, $b, $c) {
    // $a binds to index 0
    // $b binds to index 1
    // $c binds to index 2
}

assignValues(10, 20, 30); 
```

## Technical Rules and Constraints

**1. Arity and Strict Ordering**
The number of positional arguments passed must meet the minimum arity (the number of required parameters) defined by the function signature. The order of arguments must exactly mirror the signature. Passing fewer arguments than required results in an `ArgumentCountError`.

**2. Optional Parameters**
Parameters assigned a default value become optional. In a purely positional context, to omit an optional argument and rely on its default value, all subsequent arguments must also be omitted.

Furthermore, as of PHP 8.0, declaring a required parameter after an optional parameter is deprecated and generally treated as if all preceding parameters are required.

```php theme={"dark"}
// Valid signature: Optional parameters at the end
function configure($host, $port = 80, $timeout = 30) {}

// Valid invocation: Omitting $timeout
configure('localhost', 443); 

// Deprecated signature (PHP 8.0+): Required parameter follows optional
function invalidSignature($port = 80, $host) {}
```

**3. Variadic Parameters**
Positional arguments can be captured dynamically using the splat operator (`...`). When placed at the end of a parameter list, it aggregates all remaining unmapped positional arguments into a numerically indexed array.

```php theme={"dark"}
function captureData($primary, ...$overflow) {
    // $primary binds to 'A'
    // $overflow binds to ['B', 'C', 'D']
}

captureData('A', 'B', 'C', 'D');
```

**4. Argument Unpacking**
Conversely, an array or `Traversable` object can be unpacked into positional arguments during invocation using the splat operator. The array values are distributed sequentially to the function's parameters.

```php theme={"dark"}
function multiply($x, $y, $z) {}

$values = [2, 4, 6];
multiply(...$values); // Equivalent to multiply(2, 4, 6)
```

## Interaction with Named Arguments

With the introduction of named arguments in PHP 8.0, positional and named arguments can be mixed within a single invocation. However, the PHP parser enforces a strict syntactic rule: **positional arguments must always precede named arguments**. Once a named argument is declared in the call stack, no further positional arguments may be passed.

```php theme={"dark"}
function connect($host, $user, $password, $port) {}

// Valid: Positional arguments precede named arguments
connect('localhost', 'admin', port: 3306, password: 'secret');

// Fatal Error: Cannot use positional argument after named argument
// connect('localhost', user: 'admin', 'secret', 3306);
```

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