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

Testing and assertions

Compare an observable result against an explicit expectation and include boundary cases.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

Dates and time zones

DateTimeImmutable returns a new object when modified.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

Traits and enumerations

Use an enum to close the set of allowed cases and a trait to share methods between types.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

Type conversion

An explicit cast applies conversion rules for the target type.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

Type system and declarations

Type declarations check arguments, return values and properties.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

Variables and assignment

A dollar sign introduces a case-sensitive variable name.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

zend.assertions

The zend.assertions directive controls compilation and execution of assert expressions.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

FILTER_VALIDATE_EMAIL

FILTER_VALIDATE_EMAIL selects PHP’s email syntax validator.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

INF

INF is the positive floating-point infinity, and negation produces negative infinity.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

PHP_INT_MAX / PHP_INT_MIN

The pair PHP_INT_MAX / PHP_INT_MIN names the largest and smallest native signed integers, with limits dependent on the build’s integer width.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

PASSWORD_BCRYPT

PASSWORD_BCRYPT explicitly selects bcrypt for password_hash.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

PHP_EOL

PHP_EOL is the platform-specific line ending of the PHP runtime: LF on Unix-like systems and CRLF on Windows.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

STR_PAD_LEFT

STR_PAD_LEFT selects left padding in str_pad to reach a target byte length.

Intermediate · PHP 8.4; repository runtime, production runtime not attested
PHP

Capturing by reference in a PHP closure: `use (&$vat)`

In PHP, `use (&$vat)` lets a closure share a variable with the scope where the closure was created. Without `&`, the closure keeps the scalar value from creation time.

Advanced · PHP 8.3; extension availability may vary
PHP

Exception::getMessage — read an exception message

Read the text of a caught exception, distinguish it from the code and stack trace, and decide what belongs in a log versus a user-facing response.

Intermediate · PHP 8.3; extension availability may vary
PHP

Iterating by reference with foreach and &$p

Use `&$p` to update array elements directly in a `foreach` loop. Call `unset($p)` afterward so a later assignment does not accidentally overwrite an array element.

Advanced · PHP 8.3
PHP

`foreach` by reference with `&$row`

Use `&$row` to update array elements in place, then call `unset($row)` after the loop to detach the reference to the last visited element.

Advanced · PHP 8.3
PHP

Iterating over an array by reference with `foreach`

Put `&` before the value variable to edit array elements in place. Call `unset($p)` after the loop so later assignments cannot change the last visited element through that variable.

Intermediate · PHP 8.3
PHP

PHP: foreach by reference and by value

Use `&$value` to update array elements in place, and learn why `unset($value)` prevents a later loop from accidentally overwriting the last element.

Advanced · PHP 8.3
PHP

Iterator::current — read the current value

Read the value at an iterator’s current position without advancing it. Use `valid()` to check the position so that `null` and `false` are not mistaken for the end of iteration.

Advanced · PHP 8.3