Tak Tak - 5 months ago 14
PHP Question

Italic text inside echo in php html

I'm trying to itlic the text inside a Php condition but it's not working as it displays the tags instead of applying it. And I only want the

Text to be italic
to be italic, but if the other value was true
$this->input->getinput()
then no italic needed.

<input
type="text" required
class= "form-control"
id = "id"
name = "name"
value= "<?php echo (!empty($this->input->getinput()))? $this->input->getinput(): '<a style="text-align: center"><i>Text to be italic</i></a>'?>"
title = "title"
/>

Answer

You cannot use styles into value sub tags

Please try below code

<input
        type="text" required
        class= "form-control"
        id   = "id"
        name = "name"
        <?php echo (!empty($this->input->getinput())) ?  ' value="'.$this->input->getinput().'" ' : ' style="font-style: italic" value="Text to be italic" '; ?>
        title = "title"
/>
Comments