我编写了一些代码来帮助我工作,这可以将字符串/blob文本转换为可以用作元数据的内容。
我写了以下文章,但只有还原作品.我对PHP很陌生,所以对我来说,这简直令人费解!
<?php
$text = $_POST['field'];
if(isset($_POST['convert'])){
$trans = array("&" => "&", "\"" => """, "“" => """, "”" => """, "'" => "'", "<" => "<", ">" => ">");
} else if(isset($_POST['revert'])){
$trans = array("&" => "&", """ => "\"", "'" => "'", "<" => "<", ">" => ">");
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>GentetCreations</title>
<meta name="description" content="website description" />
<meta name="keywords" content="website keywords, website keywords" />
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body>
<div id="main">
<?php include("inc/pageHead.php"); ?>
<div id="site_content">
<?php include("inc/side.php"); ?>
<div id="content">
<form method="POST" action="metaConvert.php" id="convertMeta">
<table>
<tr>
<td>
<textarea id="field" name="field" rows="20" cols="80" autofocus><?php echo strtr($text, $trans); ?></textarea>
</td>
</tr>
<tr>
<td>
<p style="padding-top: 15px">
<input class="submit" name="convert" value="Convert" type="submit">
<input class="submit" name="revert" value="Revert" type="submit">
</p>
</td>
</tr>
</table>
</form>
</div>
</div>
<?php include("inc/footer.php"); ?>
</div>
</body>
</html>我在我一直在创建的网站上有一个现场演示:Www.gentetcreations.co.uk/metConvert.php
发布于 2014-12-18 14:06:51
您的代码实际上有效,但您必须对“未编码”文本进行html编码,以显示“原样”。试试这个:
<?php echo htmlspecialchars(strtr($text, $trans)); ?>发布于 2014-12-18 13:51:48
htmlspecialchars()执行此转换
https://stackoverflow.com/questions/27547914
复制相似问题