Php 使用变量更改echo语句中的文本颜色

Php 使用变量更改echo语句中的文本颜色,php,Php,例如,给我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/> 使用下面的代码,希望它能帮助你 &l

例如,给我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/>


使用下面的代码,希望它能帮助你

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


不需要
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的评论更新

为了简单起见,这里有一个示例:

<?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>

标题
答:链接{color:#0000FF;文本装饰:无;字体重量:正常;}
答:访问{颜色:#0000FF;文本装饰:无;字体重量:正常;}
a:hover{color:#0000FF;文本装饰:下划线;字体重量:正常;}
a:活动{color:#0000FF;文本装饰:无;字体重量:正常;}

但是有多个语法错误。抱歉,我没有支付提示:)仍然有一个!此外,
$test
!==
$var
这个小细节,完成:)你们在这个答案上比getl0st付出了更多的努力。我如何应用css来打印video@Miguel我已经更新了我的答案。
<?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>