阿里云新用户优惠

实例 简单个人博客

一、项目介绍 1、实例图 2、代码目录结构 admin 后台目录 article.php 文章管理列表页 article_add.php 新增文章数据处理页 article_delete.php 删除文章数据处理页 article_edit.php 编辑文章显示页 article_update.php 修改文章数据处理页 footer.php 管理界面页脚 header.php 管理界面页头 index.php 新增文章显示界面 about.php 作者简介 article.php 文章内容页 bg.jpg 背景图 comment.php 评论显示页 comment_add.php 新增评论数据页 data.json 数据储存文件 footer.php 前台页脚 header.php 前台页头 index.php 博客首页 3、数据库结构 JSON是一种轻量级的数据交换格式,易于人阅读和编写。同时也易于机器解析和生成。 JSON有两种结构,一是“名称/值”对的集合,类似关联数组;二是值的有序列表,类似索引数组。 [ { "id": 1, //文章id "title": "王者荣耀:最强的全能射手", //文章标题 "describe": "哈喽大家好,在王者荣耀里...", //内容简介 "content": "在王者荣耀里,射手位置的热度总是高于其他位置,", //文章内容 "comments": [ //评论 { "name": "admin", //评论用户名称 "comment": "你好" //评论内容 } ] } ] 4、相关函数 json_decode() — 对 JSON 格式的字符串进行解码 //语法格式: json_decode( string $json, bool $assoc = false, int $depth = 512, int $options = 0 ): mixed //assoc 当该参数为 true 时,将返回 array 而非 object 。 $datas = json_decode($dataJson, true); json_encode() — 对变量进行 JSON 编码 //语法格式: json_encode( mixed $value, int $options = 0, int $depth = 512 ): string|false $data = json_encode($datas); file_get_contents() — 将整个文件读入一个字符串 //语法格式: file_get_contents( string $filename, bool $use_include_path = false, resource $context = ?

阅读更多...