Skip to content

Instantly share code, notes, and snippets.

@Gix075
Last active February 28, 2018 18:55
Show Gist options
  • Save Gix075/c3a1d627c109e03a88dcac03c39cdab3 to your computer and use it in GitHub Desktop.
Save Gix075/c3a1d627c109e03a88dcac03c39cdab3 to your computer and use it in GitHub Desktop.
Very stupid but useful PHP functions
<?php
/* VERY SIMPLE UTILITIES */
/* ************************************** */
/*
* PRINT OBJECT/ARRAY
* Print and object or array inside <pre></pre> tags
*/
function printObject($object) {
echo "<pre>";
print_r($object);
echo "</pre>";
}
// Just an alias
function printArray($object) {
printObject($object)
}
/*
* SHOW PHP ERRORS
* Change PHP ini set for error showing
*/
function showErrors() {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
/*
* SANITIZE STRING
* Change a string to lowercase and remove white spaces
* $no_space can be one of FALSE or another symbol for white space substituion
*/
function sanitizeString($string, $lowercase = TRUE , $no_space = "") {
if ($no_space != FALSE) {
$string = str_replace(" ",$no_space,$string);
}
if ($no_space != FALSE) {
$string = strtolower($string);
}
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment