 (defconst php-types
   (eval-when-compile
     (regexp-opt '("array" "bool" "boolean" "char" "const" "double" "float"
-		  "int" "integer" "long" "mixed" "object" "real"
-		  "string")))
+                  "int" "integer" "long" "mixed" "object" "real"
+                  "string")))
   "PHP types.")
 
 (defconst php-superglobals
   (eval-when-compile
     (regexp-opt '("_GET" "_POST" "_COOKIE" "_SESSION" "_ENV" "GLOBALS"
-		  "_SERVER" "_FILES" "_REQUEST")))
+                  "_SERVER" "_FILES" "_REQUEST")))
   "PHP superglobal variables.")
+ 
 ;; Set up font locking
 (defconst php-font-lock-keywords-1
   (list
    ;; Fontify constants
    (cons
-    (concat "\\<\\(" php-constants "\\)\\>")
-    'font-lock-constant-face)
+    (concat "[^_$]?\\<\\(" php-constants "\\)\\>[^_]?")
+    '(1 font-lock-constant-face))
 
    ;; Fontify keywords
    (cons
-    (concat "\\<\\(" php-keywords "\\)\\>")
-    'font-lock-keyword-face)
+    (concat "[^_$]?\\<\\(" php-keywords "\\)\\>[^_]?")
+    '(1 font-lock-keyword-face))
 
    ;; Fontify keywords and targets, and case default tags.
-   (list "\\<\\(break\\|case\\|continue\\)\\>[ \t]*\\(-?\\(?:\\sw\\|\\s_\\)+\\)?"
-	 '(1 font-lock-keyword-face) '(2 font-lock-constant-face t t))
+   (list "\\<\\(break\\|case\\|continue\\)\\>\\s-+\\(-?\\sw+\\)?"
+         '(1 font-lock-keyword-face) '(2 font-lock-constant-face t t))
    ;; This must come after the one for keywords and targets.
-   '(":" ("^[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)[ \t]*:[ \t]*$"
-	  (beginning-of-line) (end-of-line)
-	  (1 font-lock-constant-face)))
+   '(":" ("^\\s-+\\(\\sw+\\)\\s-+\\s-+$"
+          (beginning-of-line) (end-of-line)
+          (1 font-lock-constant-face)))
 
    ;; treat 'print' as keyword only when not used like a function name
    '("\\<print\\s-*(" . php-default-face)
    '("\\<print\\>" . font-lock-keyword-face)
 
    ;; Fontify PHP tag
-   '("<\\?\\(php\\)?" . font-lock-constant-face)
-   '("\\?>" . font-lock-constant-face)
+   (cons php-tags-key font-lock-preprocessor-face)
 
    ;; Fontify ASP-style tag
-   '("<\\%\\(=\\)?" . font-lock-constant-face)
-   '("\\%>" . font-lock-constant-face)
+   '("<\\%\\(=\\)?" . font-lock-preprocessor-face)
+   '("\\%>" . font-lock-preprocessor-face)
 
    )
   "Subdued level highlighting for PHP mode.")

  :group 'php)

(defcustom php-mode-force-pear nil
  "Normally PEAR coding rules are enforced only when the filename contains \"PEAR\"\
Turning this on will force PEAR rules on all PHP files."
  :type 'boolean
  :group 'php)

(eval-when-compile
  (defconst php-mode-modified
    (save-excursion
      (and
       (re-search-backward "^;; Modified: \\(.*\\)" nil 'noerror)
       (match-string-no-properties 1)))
    "PHP Mode version number."))

(defun php-mode-version ()
  "Display string describing the version of PHP mode"
  (interactive)
  (message "PHP mode %s of %s"
	   php-mode-version-number php-mode-modified))

(defconst php-beginning-of-defun-regexp
  "^\\s *function\\s +&?\\(\\(\\sw\\|\\s_\\)+\\)\\s *("
  "Regular expression for a PHP function.")

(defun php-beginning-of-defun (&optional arg)

      (set-buffer buf)
      (goto-char (point-min))
      (when (re-search-forward
             (format "function\\s-+%s\\s-*(\\([^{]*\\))" tagname)
             nil t)
        (setq arglist (buffer-substring-no-properties
                       (match-beginning 1) (match-end 1)))))
    (if arglist
        (message "Arglist for %s: %s" tagname arglist)
        (message "Unknown function: %s" tagname))))

;; Define function documentation function
(defun php-search-documentation ()
  "Search PHP documentation for the word at point."
  (interactive)
  (browse-url (concat php-search-url (current-word t))))

