JATools and PHP Cheatsheet

I have put together a very small PHP class of useful functions. It is designed only for a development environment, not in production.

A zip file containing the class and cheatsheet.php (an example page that uses JATools to display a list of defined variables, functions etc) directly from my website.

Available JATools functions:

  • write($var)
    Echos the contents of a variable between BR tags and ###’s so as to be distinguishable – good for strings/numbers.
  • write_r($var)
    Wraps the ouput of print_r($var) between a pair of PRE tags – good for arrays or variables of unknown type.
  • writeArrayNicely($array, $depth=1, $recurse=true)
    Writes out the contents of an array in graphically pleasing way – good for figuring out the structure of an array. $depth is used by the function when recursively calling itself. $recurse can be set to false to prevent the function from repeatedly calling itself – will cause only one dimension of the array to be shown.
  • startTimer()
    Starts a php microtime timer – good for testing page generation times.
  • getTime()
    Echos the current time of the timer started by startTimer(). You can call this repeatedly throughout a page to find out which parts take the most time.
Advertisements

About Mr Chimp

I make music, draw pictures, browse the internet, programme, and make sweet, sweet cups of tea until the early hours.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

One Response to JATools and PHP Cheatsheet

  1. Daniel says:

    Thanks for this its well useful.

    If you are running this on a *inx server (case sensitive file system) you need to update the file name from JATools.php to JaTools.php as it is referred to in cheetsheet.php or update the include code in the cheetsheet.php file.

    Otherwise you’ll get the error:

    Warning: require_once(includes/jaTools.php) [function.require-once]: failed to open stream: No such file or directory in /home/sites/…

    Fatal error: require_once() [function.require]: Failed opening required ‘includes/jaTools.php’ (include_path=’.:/usr/share/pear5′) in /home/sites/…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s