Let $f(x)=x$ if $0\lt x\lt 2$, and $f(0)=f(2)=1$.
This function is not continuous on $]0,2]$. That is unavoidable, since a function continuous on a closed interval $[a,b]$ attains a maximum and a minimum on that interval.
Let $f(x)=x$ if $0\lt x\lt 2$, and $f(0)=f(2)=1$.
This function is not continuous on $]0,2]$. That is unavoidable, since a function continuous on a closed interval $[a,b]$ attains a maximum and a minimum on that interval.