Skip to content
Omni Academy
Search courses and lessons
Search
Courses
Backend Development
9
Databases
1
Frontend Development
5
Data Science
5
All courses →
Playground
HTML & CSS
JavaScript
TypeScript
Python
PHP
Ruby
Light
Dark
Auto
Sign in
Get started
All
Backend Development
Databases
Frontend Development
Data Science
Playground
Blog
HTML
JS
TS
PY
PHP
RB
← Courses
📄
Reading input
Run as I type
Reset
▶
Run
Ctrl
↵
PHP
PHP source code
<?php // fgets(STDIN) reads the Input box below the editor - one line per call. // Two lines are waiting there already; change them and run again. $name = trim(fgets(STDIN)); $year = (int) trim(fgets(STDIN)); $age = 2026 - $year; echo "Hello, {$name}.\n"; echo "You turn {$age} this year.\n"; echo match (true) { $age >= 18 => "Old enough to vote in most places.\n", default => (18 - $age) . " years until you can vote in most places.\n", }; // (int) on something that is not a number gives 0 rather than raising, // which is why validating input is your job and not the language's. var_dump((int) "not a number");
Input
one line per
input()
call
Aisha 1997
Output
Rendered by your browser