3v4l.org

run code in 300+ PHP versions simultaneously
<?php // to $_POST['costam'] $test = ["1", "2", "d21", "11x1", "-11", "sdd", "-55421", "4444444", "23.34", "0"]; foreach( $test as $val) { $liczba = (int)($val); // sposob 1 if($liczba === false || $liczba < 0){ echo"To nie jest liczba ". $val. PHP_EOL; } else { echo "To jest liczba. ". $val . PHP_EOL; } echo "---------------------------" . PHP_EOL; // sposob 2: $opts = [ 'options' => [ 'min_range' => 0, 'max_range' => PHP_INT_MAX ]]; $test = filter_var($val, FILTER_VALIDATE_INT, $opts); if($test === false){ echo"To nie jest liczba ". $val. PHP_EOL; } else{ echo"To jest liczba ". $val. PHP_EOL; } echo PHP_EOL.PHP_EOL.PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
To jest liczba. 1 --------------------------- To jest liczba 1 To jest liczba. 2 --------------------------- To jest liczba 2 To jest liczba. d21 --------------------------- To nie jest liczba d21 To jest liczba. 11x1 --------------------------- To nie jest liczba 11x1 To nie jest liczba -11 --------------------------- To nie jest liczba -11 To jest liczba. sdd --------------------------- To nie jest liczba sdd To nie jest liczba -55421 --------------------------- To nie jest liczba -55421 To jest liczba. 4444444 --------------------------- To jest liczba 4444444 To jest liczba. 23.34 --------------------------- To nie jest liczba 23.34 To jest liczba. 0 --------------------------- To jest liczba 0

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54 ms | 402 KiB | 8 Q