Skip to content

Instantly share code, notes, and snippets.

@ChristianOellers
Created April 26, 2019 12:09
Show Gist options
  • Save ChristianOellers/4f62974b71d31cf49ab6eb8a09b0a51e to your computer and use it in GitHub Desktop.
Save ChristianOellers/4f62974b71d31cf49ab6eb8a09b0a51e to your computer and use it in GitHub Desktop.
Contao CMS - Get global variables by type - Prevent memory allocation error - Workaround
<?php
/**
* Return parts of the $GLOBALS array sorted by type.
* It's recommended to not return all at once as this might run out of memory.
*/
foreach (array_keys($GLOBALS) as $key) {
switch (gettype($GLOBALS[$key])) {
case 'array': {
debug(array_keys($GLOBALS[$key]));
break;
}
case 'object': {
debug(get_class_methods($GLOBALS[$key]));
break;
}
default: {
debug($GLOBALS[$key]);
break;
}
}
}
function debug ($value) {
// Add own debugging methods here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment