/** * printarr * * Print an array * * @param mixed $a Any array * @param string $descr Description to print above output, optional * @return void **/ function printarr($a, $descr = '') { if (!is_array($a)) { ob_start(); if (!empty($descr)) { printbr('<b>' . $descr . '</b>'); } var_dump($a); $str = ob_get_clean(); printNicely($str); } else { ob_start(); print '<pre>'; if (!empty($descr)) { print '<b>' . $descr . '</b>' . "\n"; } print_r($a); print '</pre>'; $str = ob_get_clean(); printNicely($str); } }
protected function checkSigninFail(Exception $e) { printbr('check sign in fail'); }
<?php /* function some_function( $argument1, $argument2) { //functioncode } */ function seb() { print "<h1>HALLO SEBASTIAN!</h1>"; } seb(); function printbr($txt) { print "{$txt}<br>\n"; } printbr("hei på deg"); printbr("dette er en ny linje"); function addnum($firstnum, $secondnum) { $result = $firstnum + $secondnum; return $result + seb(); } print addnum(50, 4); ?> </section> </main> </body> </html>
$defaults = ['DebugMode' => false, 'TestClassRegex' => '(.+)Test', 'ReporterClass' => 'HtmlReporter']; // note that this can be overridden by "config.json" ob_start(); // Initialize configuration $fileConfig = realpath(__DIR__ . "/config.json"); $config = $defaults; if ($fileConfig === false || !file_exists($fileConfig)) { echo concat("<b>Warning:</b> Config file <b>", __DIR__ . "/config.json", "</b> not found. Will use the defaults.<br>"); } else { $config = json_decode(file_get_contents($fileConfig), true); if (empty($config)) { echo "<b>Warning:</b> Config file is not a valid JSON configuration. Will use the defaults.<br>"; } } echo "<br><br>Proceeding using the following configuration:<br>"; printbr(nl2br(str_replace(" ", " ", \Zend\Json\Json::prettyPrint(json_encode($config, true)))), true); $debug_output = ob_get_clean(); if ($config['DebugMode']) { echo $debug_output; } // Load and Run all test files $recursiveIterator = new RecursiveDirectoryIterator(__DIR__, RecursiveDirectoryIterator::SKIP_DOTS); $it = new RecursiveIteratorIterator($recursiveIterator); $regexIterator = new RegexIterator($it, '/Test\\.php$/'); foreach ($regexIterator as $key => $value) { // By default, we only get classes which names end with "Test", e.g. MyUtilityTest, etc. $classname = preg_replace(sprintf('/(.+)(\\/|\\\\)(%s)\\.(.+)$/i', $config['TestClassRegex']), '$3', (string) $value); if ($classname == $value) { continue; } require_once (string) $value;