Skip to content

Instantly share code, notes, and snippets.

@akamola
Last active May 13, 2021 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akamola/a8d9d4b7cb949e9fcf66de2280eb465b to your computer and use it in GitHub Desktop.
Save akamola/a8d9d4b7cb949e9fcf66de2280eb465b to your computer and use it in GitHub Desktop.
PHP: Quick Helper Functions

PHP: Quick Helper Functions

This is a small collection of quick helper functions for debugging and working with PHP.

Functions

axyz_d()

axyz_d( $var )

Dump any variable, formatted.

axyz_e()

axyz_e( $msg )

Log a message to the PHP error log.

axyz_r()

axyz_r( $var )

Dump any variable to the PHP error log.

axyz_x()

axyz_x( $var )

Dump any variable, formatted, and stop the script.

<?php
/**
* Dump any variable, formatted.
* @param mixed
* @return void
*/
function axyz_d( $var ) {
echo '<pre>';
var_dump( $var );
echo '</pre>';
}
/**
* Log a message to the PHP error log.
* @see https://www.php.net/manual/function.error-log.php
* @param mixed
* @return void
*/
function axyz_e( $msg ) {
error_log( $msg );
}
/**
* Dump any variable to the PHP error log.
* @see https://www.php.net/manual/function.error-log.php
* @param mixed
* @return void
*/
function axyz_r( $var ) {
error_log( print_r( $var ) );
}
/**
* Dump any variable, formatted, and stop the script.
* @param mixed
* @return void
*/
function axyz_x( $var ) {
echo '<pre>';
var_dump( $var );
echo '</pre>';
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment