2017-04-23 69 views
-2

,让我的echo语句和白色,怎么给一个蓝色的文字文本echo语句,例如更改文本颜色与可变

<?php 
$testo = file_get_contents('testi.txt'); 
echo $testo; 
?> 

TXT文件是由许多像这样的例子链接

<a href='https://www.example.com/playlist/film1.mp4' target='blank'>Example text1</a><br/> 

回答

1

无需php这里,使用css

a:link { color:#0000FF; text-decoration:none; font-weight:normal; } 
a:visited { color: #0000FF; text-decoration:none; font-weight:normal; } 
a:hover { color: #0000FF; text-decoration:underline; font-weight:normal; } 
a:active { color: #0000FF; text-decoration:none; font-weight:normal; } 

基于OP的评论更新

several ways to add css to your file,为简单起见,这里是一个例子:

<?php 
$links = file_get_contents("links_from_text_add_css.txt"); 
?> 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Title</title> 
    <style type="text/css"> 
     a:link { color:#0000FF; text-decoration:none; font-weight:normal; } 
     a:visited { color: #0000FF; text-decoration:none; font-weight:normal; } 
     a:hover { color: #0000FF; text-decoration:underline; font-weight:normal; } 
     a:active { color: #0000FF; text-decoration:none; font-weight:normal; } 
    </style> 
</head> 
<body> 
<?=$links?> 
</body> 
</html> 
+0

我如何应用css打印彩色链接到视频 – Miguel

+0

@Miguel我已经更新了我的答案。 –

0
<?php 

$var = "test"; 

echo "<p style='color:#AFA;'>" . $var . "</>"; 

你去那里

+4

虽然这里有多个语法错误。 – Qirel

+0

对不起,没有注意:) – getl0st

+0

还有一个!另外,'$ test'!=='$ var' – Qirel

1

使用belowcode希望这将有助于你

<?php 
    $testo = file_get_contents('testi.txt'); 
    echo "<p style=\"color:#000\">".$testo."</p>"; 
    ?>