Core:Utils Class

From Habari Project

Revision as of 03:00, 9 November 2010 by Chrismeller (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Utils class has bunches of useful functions.


Contents

debug

When tracing through the Habari source code, sometimes it's useful to display the value of a variable at a certain place in execution. Normally, you might use the PHP command print_r() to output this information, but without some extra markup, this may cause some formatting issues, and doesn't provide all of the information that might be useful for debugging.

Instead, Habari provides the Utils::debug command, which produces output like print_r(), but formats it nicely and provides a call stack. The call stack can be expanded to show the functions that were executed to arrive at that point in code. Each of the functions displayed also shows the parameter types passed to that function, and if you click on them they will toggle, revealing the parameter values.

To call Utils::debug(), you may pass zero or more parameters, the values of each will appear in the output along with their type information:

Utils::debug($foo, $bar, $baz);


firedebug

This is a lot like debug, except it outputs the data in the firebug console.

Utils::firedebug($post);

getdate

returns an array of date information.

par: a unix timestamp. The function

 Utils::getdate('1226631683');

Would return an array like the one below.

    [seconds] => 23
    [minutes] => 1
    [hours] => 3
    [mday] => 14
    [wday] => 5
    [mon] => 11
    [year] => 2008
    [yday] => 318
    [weekday] => Friday
    [month] => November
    [0] => 1226631683
    [mon0] => 11
    [mday0] => 14

php_check_syntax

Checks the syntax of specified code.

par: the code one wants to check return: returns true or false.

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, erlang, f1, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, plsql, postgresql, povray, powerbuilder, powershell, progress, prolog, properties, providex, purebasic, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, z80, zxbasic

This page describes a PHP class that is in the Habari software. For more comprehensive technical information visit the API Documentation.
Other Class Pages
Personal tools