<?php function write_log($file, $txt) { $f = fopen('log/' . $file, 'a+'); fwrite($f, date('c') . " " . $txt . "\n"); fclose($f); } def('path', function () { return implode('/', bu::path()); }); def_alias('bu::path', 'pth'); def_alias('bu::view', 'view'); def('dview', function ($pth, $data) { return view($pth, array('data' => $data)); }); def('map_dview', function ($tpl, $array, $separator = '') { return implode($separator, map(function ($v) use($tpl) { return dview($tpl, $v); }, $array)); }); def_sprintfer('cehr', '<div style="cehr"><center>-----------</center></div>');
<?php // def_sprintfer - делает тоже что и def_printfer, но используя функцию sprintf def_sprintfer('h1', '<h1>%s</h1>'); $v = h1('hello!'); echo ">" . $v . "<"; ?> --- ><h1>hello!</h1><
<?php require_once 'load.php'; def_printfer('h1', "<h1>%s</h1>\n"); h1('Hello, '); h1('World!'); // <h1>Hello, </h1> // <h1>World!</h1> def_printfer('puts', "%s\n"); puts("text"); // text ////////////////////////////////////////////////// def_sprintfer('a', "<a href='%s'>%s</a>"); def_sprintfer('img', "<img src='%s'>"); def('def_tag', function ($name) { def_sprintfer($name, "<{$name}>%s</{$name}>\n"); }); foreach (array('p', 'div', 'html', 'head', 'body', 'title', 'h1') as $tag) { def_tag($tag); } echo html(head(title('Hello, World!')) . body(div(h1('Hello, World!')) . div(p("This is a page about world!") . a("http://world.com", img("http://world.com/logo.jpg"))))); /* <html><head><title>Hello, World!</title> </head> <body><div><h1>Hello, World!</h1> </div> <div><p>This is a page about world!</p> <a href='http://world.com'><img src='http://world.com/logo.jpg'></a></div> </body> */ //////////////////////////////////////////////////