$this->getDefcode() ]); } private function evaluateCode($code) { ini_set('display_errors', true); ini_set('display_startup_errors', true); ini_set('display_not_found_reason', true); ini_set('display_exceptions', true); ini_set('html_errors', false); error_reporting(E_ALL | E_STRICT); ob_start(); $memBefore = memory_get_usage(true); $startTime = microtime(true); // Remove the validate($request, [ 'code' => 'required' ]); $out = $this->evaluateCode($request->code); if ($request->wantsJson()) { $resp = Response::json([ 'output' => $out['output'] . "\n#end-php-console-output#", 'memory' => sprintf('%.3f', $out['memory']), 'duration' => sprintf('%.3f', $out['duration']) ], 200); return $resp; } else { // Full HTML page return view('debug.sandbox', [ 'code' => $request->code, 'defcode' => $this->getDefcode(), 'output' => $out['output'] ]); } } private function getDefcode() { return <<