简体   繁体   English

如何在php中为联系表单页面加粗文本?

[英]how to bold text in php for the contact form page?

I have a simple PHP code where I need the name, phone num and remaining details of the user in bold. 我有一个简单的PHP代码,我需要用粗体显示姓名,电话号码和用户的其他详细信息。 But when I use it is displaying the same but the text wont appear in bold. 但是,当我使用它时,它显示的是相同内容,但文本不会以粗体显示。

      <?php
       $Name = $_POST['Name'];
       $Email = $_POST['Email'];
       $phone= $_POST['phone'];
       $formcontent= 
                     "Name: $Name\n
                      Contact Number: $phone \n
                      Email: $Email";
      ?>

If the person name is sandy then sandy only should display in bold. 如果人名是沙色的,则沙色仅应以粗体显示。 Name: sandy . 名称: 桑迪 whether i should use bold tag or strong tag and where i should use them, I don't know what to use for this code. 无论我应该使用粗体标签还是强标签以及应该在哪里使用它们,我都不知道该代码使用什么。 Any suggestion is helpful to me. 任何建议对我都有帮助。

try this, it think it will help you 试试这个,它认为它将为您提供帮助

$formcontent= 
                     "Name: <b>$Name</b>\n
                      Contact Number: <b>$phone</b> \n
                      Email: <b>$Email</b>";

here we go: 开始了:

<?php
       $Name = "Abc";
       $Email = "abc@gmail.com";
       $phone= 1234;
       Print "Name:"."<strong>".$Name."</strong><br>";
  ?>

It is just an example, and is working well, now you can do rest of the things by yourself, here is the reference link for more info: Making PHP output Bold 这只是一个示例,并且运行良好,现在您可以自己完成其余的事情,这里是更多信息的参考链接: 使PHP输出为粗体

i hope this would help you. 希望对您有帮助。 keep coding :) 继续编码:)

Tested code 经过测试的代码

<?php

       $Name = 'sandy';
       $Email = 'sandy@gmail.com';
       $phone= '999999999999';
      echo  $formcontent= 
                     "Name:<strong>".$Name." </strong> <br>
                      Contact Number: <strong>".$phone."</strong> <br>
                      Email: <strong>".$Email."</strong><br>" ; ?>

thank for comment in my answer, how about this ? 感谢我的回答,这呢?

$Name='a'; $phone='wew'; $Email='sfdsdfs';
$formcontent= 
                     "Name: <b>$Name</b>\n
                      Contact Number: <b>$phone</b> \n
                      Email: <b>$Email</b>";

    echo strip_tags($formcontent,'<b>');

i'm waiting your respon, thanks! 我正在等待您的回复,谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM