-2

I have developed one webpage using php . I am executing some shell scripts through it and the shell scripts return some outputs (echo statements) . Those echo statements are saved in output1 , output2 etc .. This is the piece of code where I am redirecting those outputs to a text area.

<textarea>
 <?php
 echo $output1 ;
 echo $output1 ;
 ?>
</textarea>

The output is getting correctly printed in text area. I need to make those statements bold , colourful . But I cant do the same. If I add span style colour and all inside the echo , the whole thing is getting printed in text area. Please help .

Thanks

  • try this : `echo ''.$output1.'';` – prakash tank Apr 20 '18 at 09:26
  • 2
    Have you ever seen a plain textarea with anything but plain text? – deceze Apr 20 '18 at 09:29
  • Could use something like TinyMCE or CKEdit I guess; they're WYSIWYG editors that "hijack" a given text area allowing you to format the text in-situ ... but if this isn't supposed to be editable (as it's just responses from shell) why put it into a ` – CD001 Apr 20 '18 at 09:33
  • @prakashtank Its not working . coming in text area. –  Apr 20 '18 at 09:33

3 Answers3

2

textareas cannot be formatted; use some other element that can be formatted, such as a div.

.output {
  font-weight: bold;
  color: blue;
}
<div>normal</div>
<div class="output">output1 code</div>
<div class="output">output2 code</div>

like

<div class="output><?= $output1 ?></div>
<div class="output><?= $output2 ?></div>
CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
1

Early Night by Rafal Tomal

h1 { color: #ffffff; font-family: 'Lato', sans-serif; font-size: 54px; font-weight: 300; line-height: 58px; margin: 0 0 58px; }

The quick fox jumps over the lazy dog!

Edit:: You can use the contenteditable attribute. It is as follows:

<?php echo"
    <div id='mytxt' contenteditable='true'>
       Hello, my name is <span style='color: blue;'>Bob</span>
       and I have a friend name <span style='color: green;'>Joe</span>.
    </div>";

You can add the html in php for more information go here

  • 1
    I'm really struggling to work out the relevance of this to the original question tbh... – CD001 Apr 20 '18 at 09:36
  • @CD001 he asks about beautiful text,there you go,it's a css question not a php –  Apr 20 '18 at 09:37
  • It's about formatting text in a ` – CD001 Apr 20 '18 at 09:39
  • @CD001 I see but I found smth –  Apr 20 '18 at 09:42
  • @D.'s Its not a CSS question. I am priting echo in php . I need php itself. So my question is how to add beautification to the echo statements getting printed by php code –  Apr 20 '18 at 09:46
  • @NagarajKulkarni you mean this `echo '';` –  Apr 20 '18 at 09:48
  • @D.'s Yes . I need code like this . integrated inside echo statement. Could you please post the whole command –  Apr 20 '18 at 10:09
  • @NagarajKulkarni did it work?dont forget to mark it as an answer –  Apr 20 '18 at 10:22
  • No . It didnt help. It is printing the whole thing as text. Need some alternatives. Am working on the same. –  Apr 25 '18 at 12:49
0

This seems to be more of a css question. You can add this css style for your text area:

textarea {
  font-weight: bold;
  color: blue;
}
Jai
  • 74,255
  • 12
  • 74
  • 103