Skip to content

Instantly share code, notes, and snippets.

@vlakoff
Last active September 13, 2015 14:17
Show Gist options
  • Save vlakoff/cc2b9e27c4f7b15546db to your computer and use it in GitHub Desktop.
Save vlakoff/cc2b9e27c4f7b15546db to your computer and use it in GitHub Desktop.
A batch file for quickly dumping PHP expressions
@SETLOCAL
@SET expr=%*
@SET expr=%expr:"=\"%
@IF ^%expr:~-1%==^; SET expr=%expr:~0,-1%
@php -r "var_dump(%expr%);"
::A few examples:
::phpdump PHP_OS // "Everything should be made as simple as possible, but not simpler."
::phpdump ord("\n") // double quotation marks don't produce errors
::phpdump hexdec('ff'); // trailing semicolon should be omitted, yet it is supported for convenience
::phpdump 'dammit' == 0 // loose comparisons are fun sometimes: this one evaluates to true
::Thanks to the variadic signature of var_dump(),
::You can dump several expressions in one go:
::phpdump PHP_OS, ord("\n"), 'dammit' == 0
::Because assignments are indeed expressions,
::You can even use variables:
::phpdump $a=1, $b=2, $a+$b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment