Highlight PHP code with minted without <?php

mintedPHPsyntax highlighting

Is there a way to tell minted, that it should highlight the code, without having <?php at the start? I want to highlight my PHP code with minted. But it only highlights, when I use <?php at the start of the code snippet. I don´t want to use the <?php at the start, because I just want to show snippets of the code, not the whole file. It´s a pretty big document, by the following should contain the relevant parts. Minted highlights with the <?php, so I think there is nothing broken on the document site.

\documentclass
\usepackage{minted}
\begin{document}
% This produces highlighted code.
\begin{minted}{php}
    <?php echo "Hello";
\end{minted}
% This won´t.
\begin{minted}{php}
    echo "Hello";
\end{minted}
\end{document}

Best Answer

You can use the startinline option:

\documentclass{article}
\usepackage{minted}
\begin{document}
% This produces highlighted code.
\begin{minted}{php}
    <?php echo "Hello";
\end{minted}
% This won´t.
\begin{minted}[startinline]{php}
    echo "Hello";
\end{minted}
\end{document}

enter image description here