jokerfool Posted February 26, 2010 Share Posted February 26, 2010 Using the following line n php how do I highlight the word "Hello" into the color red? echo "Hello: " . $addr . "<br />\n"; Thank you Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/ Share on other sites More sharing options...
Adam Posted February 26, 2010 Share Posted February 26, 2010 I'm guessing you're after something like: echo '<span style="color:red;">Hello</span>: ' . $addr . '<br />' . "\n"; ..? Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018483 Share on other sites More sharing options...
jl5501 Posted February 26, 2010 Share Posted February 26, 2010 echo '<span style="color:red">Hello</span>: ' . $addr . "<br />\n"; Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018484 Share on other sites More sharing options...
jokerfool Posted February 26, 2010 Author Share Posted February 26, 2010 Thank you. One last question, how do I echo the output of a text file to the same screen ? Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018486 Share on other sites More sharing options...
Adam Posted February 26, 2010 Share Posted February 26, 2010 Look into file_get_contents.. Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018491 Share on other sites More sharing options...
aebstract Posted February 26, 2010 Share Posted February 26, 2010 http://www.tizag.com/phpT/fileread.php Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018492 Share on other sites More sharing options...
jokerfool Posted February 26, 2010 Author Share Posted February 26, 2010 Trying to use this: ?> <?php $homepage = file_get_contents('text.txt'); echo $homepage; ?> Doesnt seem to be working, is there something im missing? Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018499 Share on other sites More sharing options...
aebstract Posted February 26, 2010 Share Posted February 26, 2010 Is text.txt in the same directory as this php file? Why do you close your php tag and reopen it on next line? Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018501 Share on other sites More sharing options...
jokerfool Posted February 26, 2010 Author Share Posted February 26, 2010 You got a good point there, I changed that, anyways it doesnt give me an error, just doesnt display the outputted file results, the text file is in the same directory. I changed it to this: $myFile = "text.txt"; $fh = fopen($myFile, 'r'); echo $myFile; Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018502 Share on other sites More sharing options...
aebstract Posted February 26, 2010 Share Posted February 26, 2010 I just tested this: $test = file_get_contents('test.txt'); echo $test; With a test.txt in the same directory with the word test inside it. The word was echoed without a problem. I did the test cause I never work with txt files so I wanted to be sure. Either it's not in the same directory, your file name is wrong, or there isn't anything in the txt file. Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018505 Share on other sites More sharing options...
jokerfool Posted February 26, 2010 Author Share Posted February 26, 2010 Okay I got some success going here and have successfully outputted the text file, but the text file reads like one long line into the next, is it possible to seperate into columns? Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018512 Share on other sites More sharing options...
Adam Posted February 26, 2010 Share Posted February 26, 2010 HTML is a free-form language, in that it doesn't preserve whitespace by default. To force it to preserve it you can rap the text in a <pre> tag, or apply white-space:pre; to the wrapper element's CSS... Assuming you meant to preserve tab characters and the like? Link to comment https://forums.phpfreaks.com/topic/193462-color-help-please/#findComment-1018516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.