sai*_*iid 5 php mysql database string html5
为了响应API调用,我得到一个完整的HTML脚本.完全意味着它包括HTML CSS和Javascript.现在我把那个HTML作为PHP变量中的字符串.
$content = '<html>
<head>
<script>--Some javascript and libraries included--</script>
<title></title>
</head>
<body>
<style>--Some Styling--</style>
</body>
</html>';
Run Code Online (Sandbox Code Playgroud)
现在,在数据库中保存此变量的最佳方法是什么?如何?
或者您想建议的任何其他(可能是序列化或打包)?
sai*_*iid 11
我使用base64编码数据以BLOB数据类型存储在我的数据库中.样板代码如下.
$content = '<html>
<head>
<script>--Some javascript and libraries included--</script>
<title></title>
</head>
<body>
<style>--Some Styling--</style>
</body>
</html>';
Run Code Online (Sandbox Code Playgroud)
在base64中编码数据
$encodedContent = base64_encode($content); // This will Encodes
Run Code Online (Sandbox Code Playgroud)
并使用BLOB将数据保存在数据库中.现在在检索数据后,只需将其解码如下.
$ContentDecoded = base64_decode($content); // decode the base64
Run Code Online (Sandbox Code Playgroud)
现在$ contentDecoded的值是纯HTML.
| 归档时间: |
|
| 查看次数: |
21671 次 |
| 最近记录: |