在PHP链接中更改字体样式

问题描述 投票:-2回答:2

虽然我花了一些时间在这上面,但我还是找不到解决办法。点击后,我被要求显示“返回”消息。此消息必须使用与用户单击相同的字体编写。这是我的代码:

<html>
<head>
    <title>Example - Changing the font</title>
</head>
<body>
    <?php
        if (isset($_GET['fontStyle'])){
            $font=$_GET['fontStyle'];
            unset($_GET); 
            echo "<a href='Example01.php'>";
            echo "<font face=$font>Go back</font>";
            echo "</a>";
        } else{
            echo "<h1>Choose a font style</h1>";
            echo "<a href='Example01.php?fontStyle=verdana'>verdana</a><br />";
            echo "<a href='Example01.php?fontStyle=arial'>arial</a><br />";
        }
    ?>
</body>
</html>
php html css fonts
2个回答
0
投票

更改

echo "<font face=$font>Go back</font>";

echo "<span style='font-family:".$font.";'>Go back</span>";

2
投票

<font>标签不是longer supported。使用style属性和font-family属性:

    if (isset($_GET['fontStyle'])){
        $font=$_GET['fontStyle'];
        // unset($_GET); // unset $_GET array is not necessary
        echo '<a href="Example01.php" style="font-family:'.$font.';">Go back</a>';
    } else{
        echo "<h1>Choose a font style</h1>";
        echo "<a href='Example01.php?fontStyle=verdana'>verdana</a><br />";
        echo "<a href='Example01.php?fontStyle=arial'>arial</a><br />";
    }
© www.soinside.com 2019 - 2024. All rights reserved.