Define listings for PHP [closed]

Interviews General Queries 3 years ago

738 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago

 

Problem:

1) Getting the following error b.com/tag/messages">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 b.com/tag/variables">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
    {&ouml
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum


Q

Labview FPGA interview questions

Labview FPGA interview questions
Q

NCR c interview questions

NCR c interview questions ?
Q

What is Artificial Intelligence?

What is Artificial Intelligence?