3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CommentController extends AdminController { // 検証 function validateGet(string $class,string $function): mixed { $params = []; if($function === 'searchAction'){ // ★案A:コントローラ内に書く $orderBy = $_GET['orderBy'] ?? null; $oks = ['id','updatedAt']; if(in_array($orderBy,$oks,true)){ $params['orderBy'] = $orderBy; }else{ $params['orderBy'] = 'id'; } // ★汎用的な検証メソッドを使用 $uniqueId = $_GET['uniqueId'] ?? null; $validated = Validator::validateUniqueId($uniqueId); if ($validated) { // 検証失敗時はメッセージテキストが返るので, ここでそのまま返して終了 return $validated; } else { // 検証成功時はそのままセット $validatedParams['uniqueId'] = $uniqueId; } } return $params; } // 検索 function searchAction(): void { // 検証 $params = $this->validateGet(__CLASS__, __FUNCTION__); if(is_string($params)){ // エラーメッセージの文字列なら // スロー } $commentMapper = new CommentMapper(); $stmt = $commentMapper->find($params); $this->render([ 'data' => $stmt->fetchAll()->toAry() ]); } } class Validator { static function validateUniqueId(mixed $value): string { $pattern = '/^[0-9A-Za-z]{22}$/'; if (!(bool)preg_match($pattern, $value)) { return 'uniqueId is not valid.'; } return ''; } }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.15, 8.5.0
Fatal error: Uncaught Error: Class "AdminController" not found in /in/r3WMM:3 Stack trace: #0 {main} thrown in /in/r3WMM on line 3
Process exited with code 255.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
109.33 ms | 407 KiB | 5 Q