Based on this clear explanation by @David, I tried to define a command to test if a particular environment was used or not.
But I really don't know why the result is always false.
MWE
\documentclass{report}
\newif\iffoo
\newenvironment{foo}{begin}{\par end\footrue}
\newcommand{\testefoo}{\iffoo true \else false \fi}
\begin{document}
\testefoo
\begin{foo}\end{foo}
\testefoo
\end{document}
Output
false begin end false
\global\footrue