class documentation

class PhpLexer(RegexLexer):

View In Hierarchy

For PHP source code. For PHP embedded in HTML, use the HtmlPhpLexer.

Additional options accepted:

startinline
If given and True the lexer starts highlighting with php code (i.e.: no starting <?php required). The default is False.
funcnamehighlighting
If given and True, highlight builtin function names (default: True).
disabledmodules

If given, must be a list of module names whose function names should not be highlighted. By default all modules are highlighted except the special 'unknown' module that includes functions that are known to php but are undocumented.

To get a list of allowed modules have a look into the _php_builtins module:

>>> from pygments.lexers._php_builtins import MODULES
>>> MODULES.keys()
['PHP Options/Info', 'Zip', 'dba', ...]

In fact the names of those modules match the module names from the php documentation.

Method __init__ Undocumented
Method analyse​_text No summary
Method get​_tokens​_unprocessed Split text into (tokentype, text) pairs.
Class Variable ​_ident​_begin Undocumented
Class Variable ​_ident​_char Undocumented
Class Variable ​_ident​_end Undocumented
Class Variable ​_ident​_inner Undocumented
Class Variable aliases Undocumented
Class Variable filenames Undocumented
Class Variable flags Undocumented
Class Variable mimetypes Undocumented
Class Variable name Undocumented
Class Variable tokens Undocumented
Instance Variable ​_functions Undocumented
Instance Variable disabledmodules Undocumented
Instance Variable funcnamehighlighting Undocumented
Instance Variable startinline Undocumented

Inherited from Lexer (via RegexLexer):

Method get​_tokens Return an iterable of (tokentype, value) pairs generated from text. If unfiltered is set to True, the filtering mechanism is bypassed even if filters are defined.
Class Variable alias​_filenames Undocumented
Method __repr__ Undocumented
Method add​_filter Add a new stream filter to this lexer.
Class Variable priority Undocumented
Instance Variable encoding Undocumented
Instance Variable ensurenl Undocumented
Instance Variable filters Undocumented
Instance Variable options Undocumented
Instance Variable stripall Undocumented
Instance Variable stripnl Undocumented
Instance Variable tabsize Undocumented
def __init__(self, **options):

Undocumented

def analyse_text(text):

Has to return a float between 0 and 1 that indicates if a lexer wants to highlight this text. Used by guess_lexer. If this method returns 0 it won't highlight it in any case, if it returns 1 highlighting with this lexer is guaranteed.

The LexerMeta metaclass automatically wraps this function so that it works like a static method (no self or cls parameter) and the return value is automatically converted to float. If the return value is an object that is boolean False it's the same as if the return values was 0.0.

def get_tokens_unprocessed(self, text):

Split text into (tokentype, text) pairs.

stack is the inital stack (default: ['root'])

_ident_begin: str =

Undocumented

_ident_char: str =

Undocumented

_ident_end =

Undocumented

_ident_inner =

Undocumented

aliases: list[str] =

Undocumented

filenames: list[str] =

Undocumented

flags =

Undocumented

mimetypes: list[str] =

Undocumented

name: str =

Undocumented

tokens =

Undocumented

_functions: set =

Undocumented

disabledmodules =

Undocumented

funcnamehighlighting =

Undocumented

startinline =

Undocumented