PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
select * from payment;
Copy Clear
Copy Format Clear
<?php function evaluateValidResult(string $input): string { $regex = '@<\?php[^?]+\?>@'; return preg_replace_callback($regex, function($code) { return eval($code); }, $input); } $input = '[ { "headers": [ { "header": "tomorrow", "pdo_type": 2 } ], "data": [ [ "<?php echo date("Y-m-d", strtotime("tomorrow")); ?>" ] ] } ]'; echo evaluateValidResult($input); $query = " select date_add(current_date, interval 1 day) tomorrow; "; // get DB version using PDO $stmt = $pdo->prepare($query); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_NUM); $columns = []; for ($i = 0; $i < $stmt->columnCount(); $i++) { $col = $stmt->getColumnMeta($i); $columns[] = [ 'header'=>$col['name'], 'pdo_type'=>$col['pdo_type'] ]; } echo json_encode([[ 'headers' => $columns, 'data' => $rows ]], JSON_PRETTY_PRINT );
Show:  
Copy Clear