Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Define listings for PHP [closed]

Interviews General Queries

Max. 2000 characters
Tuteehub
Replies

usr_profile.png

User

( 6 months ago )

 

Problem:

1) Getting the following error messages: (a) Package Listings Error: Couldn't load requested language (b) Package Listings Error: language phpalsodigit undefined.

2) Unable to figure out how to color functions/classes/methods (PDO, sprintf, setAttribute, getMessage) and variables (everything that start with $).

Minimal Working Example (MWE):

\documentclass{scrreprt}
\usepackage{color}
\definecolor{editorGray}{cmyk}{0.6, 0.55, 0.55, 0.2}
\definecolor{editorPurple}{cmyk}{0.4, 0.9, 0, 0}
\definecolor{editorWhite}{cmyk}{0, 0, 0, 0}
\definecolor{editorOrange}{cmyk}{0, 0.8, 1, 0}
\definecolor{editorBlue}{cmyk}{0.8, 0.7, 0, 0}
\definecolor{editorPink}{cmyk}{0.01, 0.81, 0.05, 0}
\usepackage{upquote}
\usepackage{listings}

\lstdefinelanguage{PHP}{
        language=php,
        sensitive=true, 
        alsoletter={<>=-},
        otherkeywords={require_once, try, new, catch, die},  
        ndkeywords={setAttribute, getMessage},  
        morecomment=[s]{<!--}{-->},
        tag=[s]
}

\lstset{%
    % Basic design
    backgroundcolor=\color{editorWhite},
    basicstyle={\small\ttfamily},   
    frame=l,
    % Line numbers
    xleftmargin={0cm},
    numbers=left,
    stepnumber=1,
    firstnumber=1,
    numberfirstline=true,
    % Code design   
    keywordstyle=\color{editorPink}\bfseries,
    commentstyle=\color{editorGray}\ttfamily,
    ndkeywordstyle=\color{editorBlue}\bfseries,
    stringstyle=\color{editorPurple},
    % Code
    language=PHP
    alsodigit={.:;},
    tabsize=2,
    showtabs=false,
    showspaces=false,
    showstringspaces=false,
    extendedchars=true,
    breaklines=false,        
    % Support for German umlauts
    literate=%
    {Ö}{{\"O}}1
    {Ä}{{\"A}}1
    {Ü}{{\"U}}1
    {ß}{{\ss}}1
    {ü}{{\"u}}1
    {ä}{{\"a}}1
    {ö
									

what's your interest