On Tue, 2009-10-06 at 19:43 +0100, MEM wrote: > Hello all, > > I'm trying to display a div, only when some php value is set. > Since this will be near html, I'd like to keep it on one line. So, I'd love > to use shortcuts and a ternary operator for the effect. > > I'm having something like this right now, but the div still appears even if > the error is NOT set. > > <?= (isset($erros['anexo'])) ? '<div class="mensagemErro">' > .$erros['anexo'].'</div>' :''; ?> > > :( > > Can I have your help with the right syntax ? > > > Regards, > The newbie on a Humpty Dumpty wall, > Márcio > > Firstly, <?= is a bad idea, as it's not very portable and relies on short tags being on, which causes all sorts of problems should you ever need PHP to output XML. The only reason I can see that the div will always appear is a logic error. Are you sure that the $erros['anexo'] variable is not set at some point and not just set to an empty string? An empty string is very different from an unset variable. Try using var_dump($erros['anexo']); in your code somewhere to see if the it is actually an empty string instead. Thanks, Ash http://www.ashleysheridan.co.uk