<?php
header("Content-type: text/html; charset=gb2312");
$GLOBALS['host'] ='localhost';
$GLOBALS['user'] ='root';
$GLOBALS['pwd']='';
$GLOBALS['dbname']='news';
$GLOBALS['msci']='gb2312';
$mypdo=new PDO("mysql:host={$GLOBALS['host']};dbname={$GLOBALS['dbname']}","{$GLOBALS['user']}","");
$mypdo->query("set names gb2312");
$sql="选择 id,title from news where id<?";
function myos($mypdo,$sql,$data=[]){
$stmt=$mypdo->prepare($sql);
$stmt->execute(array(5));
$rs=$stmt->fetchALL();
var_dump($rs);
};
myos($mypdo,$sql);
?>