src/Base.php
function highlight($text) {
		$out='';
		$pre=FALSE;
		$text=trim($text);
		if (!preg_match('/^<\?php/',$text)) {
			$text='<?php '.$text;
			$pre=TRUE;
		}
		foreach (token_get_all($text) as $token)
			if ($pre)
				$pre=FALSE;
			else
				$out.='<span'.
					(is_array($token)?
						(' class="'.
							substr(strtolower(token_name($token[0])),2).'">'.
							$this->encode($token[1]).''):
						('>'.$this->encode($token))).
					'</span>';
		return $out?('<code>'.$out.'</code>'):$text;
	}
function highlight($text) {
		$out='';
		$pre=FALSE;
		$text=trim($text);
		if (!preg_match('/^<\?php/',$text)) {
			$text='<?php '.$text;
			$pre=TRUE;
		}
		foreach (token_get_all($text) as $token)
			if ($pre)
				$pre=FALSE;
			else
				$out.='<span'.
					(is_array($token)?
						(' class="'.
							substr(strtolower(token_name($token[0])),2).'">'.
							$this->encode($token[1]).''):
						('>'.$this->encode($token))).
					'</span>';
		return $out?('<code>'.$out.'</code>'):$text;
	}
function highlight ( $ text ) { $ out = '' ; $ pre = FALSE ; $ text = trim ( $ text ) ; if ( ! preg_match ( '/^<\?php/' , $ text ) ) { $ text = '<?php ' . $ text ; $ pre = TRUE ; } foreach ( token_get_all ( $ text ) as $ token ) if ( $ pre ) $ pre = FALSE ; else $ out .= '<span' . ( is_array ( $ token ) ? ( ' class="' . substr ( strtolower ( token_name ( $ token [ 0 ] ) ) , 2 ) . '">' . $ this -> encode ( $ token [ 1 ] ) . '' ) : ( '>' . $ this -> encode ( $ token ) ) ) . '</span>' ; return $ out ? ( '<code>' . $ out . '</code>' ) : $ text ; }
Apply syntax highlighting
@return string
@param $text string
Apply syntax highlighting