Skip to content

Instantly share code, notes, and snippets.

@navarr
Created July 11, 2010 07:05
Show Gist options
  • Save navarr/471364 to your computer and use it in GitHub Desktop.
Save navarr/471364 to your computer and use it in GitHub Desktop.
## PHP Syntax Highlighting
syntax "php" "\.php[2345s~]?$"
# color red ".*"
color red "."
color white start="<\?(php|=)?" end="\?>"
# Numbers
color magenta "[+-]*([0-9]\.)*[0-9]+([eE][+-]?([0-9]\.)*[0-9])*"
color magenta "0x[0-9a-zA-Z]*"
# Functions
color brightblue "([a-zA-Z0-9_$-]*)\("
# Constructs
color brightblue "(class|extends|goto|new) ([a-zA-Z0-9_]*)"
color green "[^a-z0-9_-]{1}(var|class|function|echo|case|break|default|exit|exit|switch|if|else|elseif|endif|foreach|endforeach|@|while|public|private|protected|return|true|false|null|TRUE|FALSE|NULL|const|static|extends|as|array|require|include|require_once|include_once|define|do|continue|declare|goto|print|in|new|try|catch)([^a-z0-9_\n-]{1}|$)"
color brightblue "[a-zA-Z0-9]+:"
# Variables
color white "\$[a-zA-Z_0-9$]*|[=!<>]"
color white "\->[a-zA-Z_0-9$]*|[=!<>]"
color brightblue "\->[a-zA-Z_0-9$-]*\("
# Special Characters
color yellow "[.,{}();'\"]"
color yellow "\["
color yellow "\]"
# Special Variables
color green "(\$this|parent::|self::|\$this-\>)"
# Bitwise Operations
color magenta "(\&|\||\^){1}"
# And/Or/SRO/etc
color green "(\&\&|\|\||::|=>|->|>|<|>=|<=|!=|!==|==|\$)"
# Online Comments
color brightyellow "(#.*|//.*)$"
# STRINGS!
color red "('(([^']|(\\\'))*)'|"(([^\"]|(\\\"))*)\")"
# Inline Variables
color white "\{\$[^}]*\}"
# PHP Tags
color red "(<\?(php)?|\?>)"
# General HTML
color red start="\?>" end="<\?(php|=)?"
# trailing whitespace
color ,green "[^[:space:]]{1}[[:space:]]+$"
# multi-line comments
color brightyellow start="/\*" end="\*/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment