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 Quote Link to comment 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"; ..? Quote Link to comment 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"; Quote Link to comment 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 ? Quote Link to comment Share on other sites More sharing options...
Adam Posted February 26, 2010 Share Posted February 26, 2010 Look into file_get_contents.. Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 26, 2010 Share Posted February 26, 2010 http://www.tizag.com/phpT/fileread.php Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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; Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.