输出JSON
2024-10-20 05:25:20
<?php
header("Content-type: text/html; charset=utf-8");
$host = '数据库IP';
$dbname = '数据库名称';
$user = '用户名';
$pw = '密码';
$pdo = new PDO("mysql:host=".$host.";dbname=".$dbname."",$user,$pw); //通过PDO连接数据库
$sql = 'SELECT * FROM `新闻表` WHERE 1 ';
$arr = $pdo->query($sql)->fetchall();
echo json_decode($arr); //输出JSON
?>
最新文章
- C#中Validating和Validated事件
- SecureCrt设置字符编码
- [设计模式] 16 迭代器模式 Iterator Pattern
- Windows下Redis中RedisQFork位置调整
- mariadb 设置远程访问
- PHP XML简介
- eclipse开发安卓时logcat的绿色加号不见了
- IPv4 forwarding is disabled. Networking will not work_问题解决
- Swift PlayGround无限Running问题
- spring cloud 学习笔记(1)
- [Swift]LeetCode840. 矩阵中的幻方 | Magic Squares In Grid
- CentOS 7 yum install cobbler2.8.3
- jenkins忘记管理员密码之解决方案
- 《了不起的 nodejs》中 TwitterWeb 案例 bug 解决
- CentOS 安装Python3、pip3
- EasyUI出现多条边框重合的问题
- HTML5 &; auto download image
- Visual Studio 2017 版本 15.5.5
- 硬盘读取不了-->;>;完美解决
- 创建pod步骤