Git Product home page Git Product logo

nf_pp's Introduction

nf_pp

nf_pp is a class designed to emulate PHP function "print_r" with some additional features.

illustration

Features

  • print scalar variables, arrays, object, resources;
  • highlight data types;
  • highlight properties scope;
  • visualize values of the boolean and NULL variables;
  • show resource type;
  • trim long strings;
  • print tree-like view for arrays and objects;
  • fold nodes in arrays and objects;
  • fold whole tree or unfold tree to a certain key;
  • display file and line where the function was called;
  • print elapsed time between function calls;
  • search in keys and values (hit ENTER or Shift+ENTER in search field to navigate).

Usage

Include nf_pp.php file, create an object and pass options to it.

include 'nf_pp.php';
$pp = new nf_pp( array( 'trimString' => 0 ) );

And use it.

$pp->pp( $val1 );
$pp->pp( $val2 );

If you don't like to create an object, you can use a shortcut function.

pp( $val, array( 'trimString' => 0 ) );

Options

trimString — Default value is 1000 simbols. 0 — disable trimming. autoCollapsed — Fold tree. Default value is FALSE. autoOpen — Array of keys or a single key which will be used to unfold the tree.

You can pass options to the function as an array or one by one in any order. For example:

pp( $val, 300, 'key' );

or

pp( $val, 'key', 0 );

or

pp( $val, 'key' );

Options are determined by types. If number is passed, then it is trimString option. If boolean is passed, then it is autoCollapsed option. If string is passed, then it is autoOpen option.

Examples

See demo.php. Online demo can be found here http://demo.alexxxnf.ru/print_r/.

Print an array. Demo

pp( $val );

Print folded array. Demo

pp( $val, TRUE );

Print folded array and unfold it to keys "c" and "subarray". Demo

pp( $val, array( 'autoOpen' => array( 'c', 'subarray' ) ) );

Print folded array and unfold it to key "c". Demo

pp( $val, array( 'autoOpen' => array( 'c' ) ) );

or

pp( $val, 'c' );

nf_pp's People

Contributors

alexxxnf avatar

Watchers

simindey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.