Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created January 30, 2012 02:45
Show Gist options
  • Save michaeltwofish/1702154 to your computer and use it in GitHub Desktop.
Save michaeltwofish/1702154 to your computer and use it in GitHub Desktop.
Get the last PHP error
lasterror() {
logpath=/usr/local/www-conf/logs/$1-phplog;
error=(${(f)$(awk -F: '/PHP Fatal error|\[error\]/ { lines[last] = NR } END { print lines[last] }' $logpath)});
[[ -n $error ]] && tail -n +$error $logpath
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment