Define listings for PHP [closed]

Interviews General Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on General Queries related to Interviews. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 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

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.