PHP version checker
Paste PHP code and see the minimum version it needs, the line that decided it, and any removed functions that cap the newest version it can run on.
No account, uploads or PHP execution. Your inputs stay on this device.
How the version checker works
It removes comments and the contents of strings, then looks for 83 language features, types, functions and classes, each tagged with the PHP release that introduced it. The highest version found is the minimum your code needs. It also flags functions that were later removed, such as each() or the mysql_* family, which set the newest version the code can run on, and a few deprecations that will show notices.
It is a pattern scan, not a full parser, so treat the answer as a strong hint. It cannot see what an extension or a Composer package needs, or code built at runtime. To confirm, run php -l with the version you are targeting, or let PHPStan or Rector analyse the project with that version set.
Put the answer in composer.json
{
"require": {
"php": ">=8.1"
},
"config": {
"platform": { "php": "8.1.0" }
}
}require.php stops Composer installing your package on an older PHP. config.platform.php makes Composer resolve dependencies as if production ran that version, which avoids the "your lock file requires PHP 8.4" surprise on deploy. The Composer constraint tester shows exactly which versions a constraint allows.
Features it detects, by version
PHP 8.6
- Partial function application (? placeholders)
- clamp()
- Readonly properties with default values
- SortDirection, Time\Duration, Io\Poll
PHP 8.5
- Pipe operator |>
- clone with ($obj, [...])
- array_first(), array_last()
- #[\NoDiscard] and (void) casts
- URI extension (Uri\…)
PHP 8.4
- Property hooks
- Asymmetric visibility (private(set))
- new without parentheses (new Foo()->bar())
- array_find(), array_any(), array_all()
- #[\Deprecated]
- mb_trim(), mb_ucfirst(), bcround(), request_parse_body()
- Dom\HTMLDocument, BcMath\Number
PHP 8.3
- Typed class constants
- #[\Override]
- Dynamic class constant fetch (Foo::{$name})
- json_validate(), mb_str_pad(), str_increment()
PHP 8.2
- readonly classes
- Disjunctive normal form types ((A&B)|C)
- true, false and null as standalone types
- #[\SensitiveParameter]
- Random\Randomizer, mysqli_execute_query()
PHP 8.1
- Enums
- Readonly properties
- never return type
- First-class callable syntax strlen(...)
- new in initializers
- Pure intersection types (A&B)
- Explicit octal notation (0o…)
- final class constants
- Fibers
- array_is_list(), enum_exists()
PHP 8.0
- match expression
- Nullsafe operator ?->
- Attributes #[...]
- Named arguments
- Constructor property promotion
- Union types (A|B)
- mixed type
- static return type
- throw as an expression
- catch without a variable
- $object::class
- str_contains(), str_starts_with(), str_ends_with()
- get_debug_type(), fdiv(), get_resource_id()
- WeakMap, Stringable, ValueError
PHP 7.4
- Arrow functions (fn)
- Null coalescing assignment ??=
- Typed properties
- Numeric literal separator (1_000)
- Spread operator in array literals
PHP 7.3
- array_key_first(), array_key_last(), is_countable(), hrtime()
PHP 7.2
- object type
PHP 7.1
- Nullable types (?Type)
- void return type
- iterable type
- Class constant visibility
- Multi-catch (catch (A | B $e))
- Array destructuring with [] and keys
PHP 7.0
- Null coalescing operator ??
- Spaceship operator <=>
- Scalar parameter types (int, float, string, bool)
- Return type declarations
- Anonymous classes
- Group use declarations
- random_int(), random_bytes(), intdiv()
PHP 5.6
- Variadic parameters and argument unpacking (...)
- Exponent operator **
- use function / use const
PHP 5.5
- Generators (yield)
- finally blocks
- ClassName::class
- password_hash() and password_verify()
PHP 5.4
- Short array syntax []
- Traits
- Binary integer literals (0b…)
PHP 5.3
- Namespaces
- Closures (anonymous functions)
- Short ternary ?:
- __DIR__
Checking which PHP version a server runs
On the command line, php -v. In code, PHP_VERSION or PHP_VERSION_ID (for example 80400 for 8.4.0), which is the easiest form to compare: if (PHP_VERSION_ID < 80100) { ... }. The CLI and the web server can run different versions, so check both. Support dates for every release are on supported PHP versions.