php - Display html in echo statement -
this question has answer here: how write php ternary operator 8 answers ok below information works im trying figure problem if displays title grade... but want put | inbetween this title | grade. my below code works if there no grade still echos |, how can echo when there value in field. because when field empty shows title | <div class="sto-info"> <span><?php echo $title; ?> <?php echo '|', $grade; ?></span> </div> you can use ternary operator: <span><?php echo $title; ?> <?php echo $grade ? '|' . $grade : ''; ?></span>