Mihdan: PHP REF
WordPress plugin: a better alternative to print_r / var_dump
★ 2stars
1forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/mihdan/mihdan-php-ref/archive/refs/heads/master.zipFrom the readme
REF, or r() is a nicer alternative to PHP's printr / vardump functions.
DEMO ##
Requirements ##
- (server) PHP 5.3+ (5.4+ displays additional info)
- (client) Any browser, except IE 8 and lower of course
Installation
Copy folder to wp-content/mu-plugins:
Usage ##
Basic example:
// display info about defined classes
r(getdeclaredclasses());
// display info about global variables
r($GLOBALS);
To print in text mode you can use the rt() function instead:
rt($var);
To terminate the script after the info is dumped, prepend the bitwise NOT operator:
~r($var); // html
~rt($var); // text
Prepending the error control operator (@) will return the information:
$output = @r($var); // html
$output = @rt($var); // text
Keyboard shortcuts (javascript must be enabled):
- X - collapses / expands all levels
- Ctrl + X - toggles display state
To modify the global configuration call ref::config():
// example: initially expand first 3 levels
ref::config('expLvl', 3);
You can also add configuration options in your php.ini file like this:
[ref]
ref.expLvl = 3
ref.maxDepth = 4
Currently available options and their default