Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

Knowledge base — PHP

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 504

PHP

Iterator::next — advance to the next element

`Iterator::next()` advances an iterator by one step without returning the element. When iterating manually, check `valid()` before reading the value with `current()`.

Advanced · PHP 8.3
PHP

Pass-by-reference parameter (`&$list`)

Putting `&` before `$list` lets a PHP function change the caller's variable. Write it in the parameter declaration, not next to the argument at the call site.

Intermediate · PHP 8.3
PHP

Pass-by-reference parameter (`&$projects`)

`&$projects` lets a function change the caller’s variable. Put `&` in the parameter declaration, not in the call.

Intermediate · PHP 8.3; extension availability may vary
PHP

Pass-by-reference parameter (`&$response`)

A parameter declared as `&$response` lets a PHP function change the caller’s variable. Put `&` in the parameter declaration, not at the call site.

Intermediate · PHP 8.3; extension availability may vary
PHP

Pass-by-reference parameter: &$session

Putting `&` before `$session` lets the function modify the caller’s array directly. The parameter does not start a PHP session or save its data.

Intermediate · PHP 8.3; extension availability may vary
PHP

Pass-by-reference parameter (`&$st`)

An ampersand before a parameter name lets the function change the caller’s variable. Write `&$st` in the declaration, but pass the variable normally: `markReady($status)`.

Intermediate · PHP 8.3; extension availability may vary
PHP

Pass-by-reference parameter (&$users)

An ampersand before the `$users` parameter lets the function change the caller’s variable without returning the array. At the call site, pass the variable without `&`.

Intermediate · PHP 8.3; extension availability may vary
PHP

Assignment by reference: $alias and $projects

Assignment by reference gives two names to the same value. Writing through either name changes the shared value; `unset($alias)` removes only the alias binding.

Intermediate · PHP 8.3; extension availability may vary
PHP

Assignment by reference (`=&`) in PHP

Use `=&` to bind two names to the same variable contents. A write through either name is visible through the other for as long as both names remain bound.

Advanced · PHP 8.3; extension availability may vary
PHP

By-reference parameter `&$res`

The ampersand before `$res` lets a function change the variable supplied by its caller instead of returning a replacement value.

Advanced · PHP 8.3; extension availability may vary
PHP

Reference parameter `&$value` versus passing by value

In PHP 8.3, a parameter declared as `&$value` lets the function change the caller’s variable. With the default pass by value, assigning to the parameter does not change that variable.

Advanced · PHP 8.3; extension availability may vary
PHP

Returning by reference: `function &getSession`

A function that returns by reference lets the caller alias a variable. Use `=&` to bind the alias; plain `=` assigns the value without creating that binding.

Intermediate · PHP 8.3; extension availability may vary
PHP

SplFixedArray::count — get the current size

`SplFixedArray::count()` returns the current number of slots, including slots that contain `null`, rather than the number of non-null values.

Advanced · PHP 8.3; extension availability may vary