function myInit($f, $title = "") { // calling file, optional title if ($title == "") { $title = basename($f); } echo ' <DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <title>' . $title . '</title> </head> <body> '; echo "<h3><a href=" . basename($f) . ">{$f}</a></h3>"; PC::db('Entering ' . $f); if ($_GET) { PC::db($_GET, "_GET"); } if ($_POST) { PC::db($_POST, "_POST"); } if ($_FILES) { PC::db($_FILES, "_FILES"); } if ($_COOKIE) { PC::db($_COOKIE, "_COOKIE"); } if ($_REQUEST) { PC::db($_REQUEST, "_REQUEST"); } }
/** * ChromeのJavaScript コンソールにメッセージを出力 * * @param string $message 出力する文字列 * @return void */ public static function log($message) { if (self::$debugMode) { if (is_array($message)) { $message = 'Array[' . str_replace('&', ", ", urldecode(http_build_query($message))) . ']'; } $message = strip_tags($message); $message = html_entity_decode($message); PC::db($message); global $LOGGER; $LOGGER->info($message); } }
param("al", $al); // mira lo que hace extract(), todavía no lo uso aquí param("ca", $ca); // seria buena idea si son muchos parametros param("vi", $vi); // empezamos el query string para pasarlo a hacer_lista() $qs = "{$yo}?"; $con = db_open($db_name); echo "KEYS:", br(); foreach (["artistas", "albumes", "canciones", "videos"] as $t) { echo "{$t} PK: ", db_getPK($db_name, $t), br(); $ka = db_getFK($db_name, $t); if ($ka[0]) { echo "{$t} FK: " . $ka[1][0][0] . " ref tabla " . $ka[1][0][1] . " col " . $ka[1][0][2] . br(); } PC::db($ka, "{$t}"); $rfk = db_getrFK($db_name, $t); if ($rfk[0]) { echo "Referencias a {$t}: ", table($rfk[0], $rfk[1]); } } // empezamos por las canciones de momento, luego veremos que hacer con los videos if ($ca) { // mostrar la cancion selecionada $qs .= "vi={$vi}&"; $videos = db_query($con, "SELECT tipo_video, enlace FROM videos WHERE id_cancion={$ca} ORDER BY 1, 2")[1]; if ($videos) { foreach ($videos as $v) { echo br(), "{$v['0']}: {$v['1']}" . t("video", t("source", "", ["src" => $v[1]]), ["width" => 320, "height" => 240, "controls" => ""]); } } else {
<?php include 'inc.php'; myInit(__FILE__); echo "testing include"; PC::db("testing if PC::db in scope"); echo md("# Testing MarkDown");
<?php require_once __DIR__ . '/../../src/PhpConsole/__autoload.php'; // Call debug from PhpConsole\Handler $handler = PhpConsole\Handler::getInstance(); $handler->start(); $handler->debug('called from handler debug', 'some.three.tags'); // Call debug from PhpConsole\Connector (if you don't use PhpConsole\Handler in your project) PhpConsole\Connector::getInstance()->getDebugDispatcher()->dispatchDebug('called from debug dispatcher without tags'); // Call debug from global PC class-helper (most short & easy way) PhpConsole\Helper::register(); // required to register PC class in global namespace, must be called only once PC::debug('called from PC::debug()', 'db'); PC::db('called from PC::__callStatic()'); // means "db" will be handled as debug tag // Debug some mixed variable class DebugExample { private $privateProperty = 1; protected $protectedProperty = 2; public $publicProperty = 3; public $selfProperty; public function __construct() { $this->selfProperty = $this; } public function someMethod() { } } PhpConsole\Connector::getInstance()->getDebugDispatcher()->setDumper(new PhpConsole\Dumper(2, 10, 40));
$reset = false; } else { // no debemos, hay que resetear, decimos porque echo $numero == $aleatorio ? "Eres {$intentos} monstruos! Otro juego?" : "Numero de intentos excedido"; } } // supuestamente no se pueden pulsar 2 botones a la vez (no es verdad) if (isset($_GET['cl_btn'])) { // cambiamos el limite? $l = $_GET['limite']; $reset = true; // descartamos intentos previos } $maxat = round(log($l, 2) + 1); // limite intentos PC::db("maxat: {$maxat}"); // para verlo en la consola de Chrome y también como un floater if ($reset) { $intentos = $maxat; $aleatorio = rand(1, $l); $numero = ""; PC::db("aleatorio: {$aleatorio}"); } // siempre mostramos el formulario echo "<br /> te quedan {$intentos} intentos (de {$maxat})<br />\n<form name='formulario' action ='{$yo}' method='GET' enctype='application/x-www-form-urlencoded'>\n\n<label>Introduce un número entre 1 y {$l}</label>\n<input type='number' name='numero' value='{$numero}' autofocus onfocus=\"this.select()\">\n<input type='hidden' name='rxz' value='{$aleatorio}'>\n<input type='hidden' name='nat' value='{$intentos}'>\n<input type='submit' name='enviar_btn' value='Comprobar'/>\n\n<br />\n<label>Cambiar el limite</label>\n<input type='number' name='limite' value='{$l}' onfocus=\"this.select()\">\n<input type='submit' name='cl_btn' value='Cambiar limite'/>\n\n</form>\n<a href='{$yo}'>Reset</a>\n"; ?> </body> </html>
function mostrar_informacion() { global $d, $t, $pk, $pki, $con, $meta; echo h3("Tabla {$t}"); echo h4("Clave primaria: {$pk} con index {$pki}"); echo h4("Claves forraneas:"); $fka = db_getFK($meta, $d, $t); if ($fka[0]) { foreach ($fka[1] as $fk) { echo h5($fk[0] . " hace referencia a " . link_table($fk[1]) . "(" . $fk[2] . ")"); } } echo h4("Referencias a esta tabla:"); $rfka = db_getrFK($meta, $d, $t); PC::db($rfka, "rfka"); if ($rfka[0]) { foreach ($rfka[1] as $rfk) { echo h5(link_table($rfk[1]) . "(" . $rfk[2] . ") hace referencia a " . $rfk[0]); } } }