如何在网页中将 php 代码和 html 标签显示为文本 [英] How to display php code and html tags as text in a web page

查看:26
本文介绍了如何在网页中将 php 代码和 html 标签显示为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下一段代码,并希望将其显示为网页中的文本.我该怎么做?我看下面提到的代码在网页中显示为文本.该页面可能是 .html 页面或 .php 页面.请帮忙.

<头><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>登录!</title><style type="text/css">div {宽度:300px;高度:120px;边距:0px 自动;边距顶部:100px;填充:30px 20px;边框:2px 实心 #00F;背景色:#0CF;边框半径:10px;}跨度{边距:0px 自动;颜色:#F00;字体系列:Verdana,日内瓦,无衬线;字体大小:12px;}</风格><身体><?phprequire_once('conn.php');$sql="select * from contacts where contacts_id=14";$result=$mysqli->query($sql);$row=$result->fetch_array();if( isset($_POST['id']) && $row['email']==$_POST['id'] && $_POST['password']==$row['password']){header("location:view.php") ;$_SESSION['sid']= $row['email'];$flag=1;}?><div><form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"><table align="center" border="0"><tr><td>Id</td><td>:</td><td><input type="text" name="id" placeholder="Email"/></td></tr><tr><td>密码</td><td>&:</td><td><input type="password" name="password"/></td></tr><tr><td></td><td colspan="2"><input type="submit" value="登录!"/></td></tr></表单><?phpif (isset($_POST['id']) &&isset($_POST['password']) && $flag==0){echo "<center><span>Invalid Id/Password</span></center>";}?>

</html>

解决方案

$gen_query_data= htmlspecialchars(' $'.$db_val_clean.'_ser = $_POST["'.$sel_name_clean.'_ser"];')."<br>";回声 $gen_query_data;

请更改您的变量

I have the following piece of code and wish to display it as text in a webpage. How can I do it? I wat the code mentioned below to be displayed as text in a webpage. The page might be either a .html page or a .php page. Kindly help.

<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Log in!</title>
 <style type="text/css">
  div {
     width:300px;
     height:120px;
     margin: 0px auto;
     margin-top: 100px;
      padding: 30px 20px;
      border:2px solid #00F;
     background-color:#0CF;
     border-radius:10px;
    }

 span{
    margin:0px auto;
     color:#F00;
      font-family:Verdana, Geneva, sans-serif;
     font-size:12px;
  }

 </style>
 </head>

<body>
 </body>
 <?php
 require_once('conn.php');

$sql="select * from contacts where contacts_id=14";
 $result=$mysqli->query($sql);
 $row=$result->fetch_array();
 if( isset($_POST['id']) && $row['email']==$_POST['id'] && $_POST['password']==$row['password'])
 {
     header("location:view.php")    ;
      $_SESSION['sid']= $row['email'];
    $flag=1;
 }
 ?>

 <div>
 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
 <table align="center" border="0">
   <tr>
      <td>Id</td>
      <td>:</td>
      <td><input type="text" name="id" placeholder="Email" /></td>
    </tr>
    <tr>
    <td>Password</td>
      <td>&:</td>
      <td><input type="password" name="password" /></td>
    </tr>
    <tr>
      <td></td>
   <td colspan="2"><input type="submit" value="Log In!" /></td>
    </tr>
 </table>
  </form>
     <?php
      if (isset($_POST['id']) && isset($_POST['password']) && $flag==0)
     {
           echo "<center><span>Invalid Id/Password</span></center>";    
      }

   ?>
    </div>
   </body>
   </html>

解决方案

$gen_query_data= htmlspecialchars(' $'.$db_val_clean.'_ser = $_POST["'.$sel_name_clean.'_ser"];')."<br>";

     echo $gen_query_data;  

please change your variables

这篇关于如何在网页中将 php 代码和 html 标签显示为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆