mercredi 7 juin 2017

PHP if statement inside HTML attribute

I was wondering something. I'm looking at code from other trainees (who left, so I can't ask anything). I see the following:

<input type="text" 
name="name" 
class="form-control" 
placeholder="name" 
value="<?php if (isset($something)): echo 'bla'; 
             else: if(!empty($somethingelse)): echo 'bla2'; endif;"
>

This actually does look pretty ugly if I say so myself. I was wondering: is this actually a "good"/okay way to do it or is it really as bad as I think?

Aucun commentaire:

Enregistrer un commentaire