1,
$a = [1,2,3,5];
foreach($a as &$item){
echo $item . ‘,‘;
}
foreach($a as $item){
echo $item . ‘,‘;
}
exit;
//1,2,3,5,1,2,3,3,
2,PHP Version 5.6.9、
$i = 2147483648232;
$b = intval($i);
var_dump($b);
$i = 01234567893456789334567;
var_dump(intval($i));
exit;
//int(232) int(342391) 不知道问什么
---
try无法获取pdo的exception
try{
$pdo=new pdo("mysql:host=127.0.0.1:3308;dbname=brush","root","root");
//主动以警告的形式报错
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION );
}catch(PDDException $e){
die(json_encode($e));
echo"数据库连接错误";exit;
}
---
try{
$a = $pdo->query("show databases; ");
foreach ($a as $key => $value) {
# code...
var_dump($value);
}
}catch(PDDException $e){
echo"数据库query错误";exit;
}