← All docs

clamp()

Clamps a value to be within a specified range.

clamp()

function clamp(int $value, int $min, int $max): mixed

Clamps a value to be within a specified range.

Parameters:

  • $value (int)
  • $min (int)
  • $max (int)

Returns: mixed

No examples yet — check examples/ and showcases/ for usage patterns.

Internals

For how clamp is implemented in the compiler, see the internals page.