14c09-1.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 33 行

PHP
33
字号
<?php// This is a small header file that will connect to the database for us//  and provide some convenience functions:// An error handling routinefunction blog_error($pdo) {    // Read the error, and exit printing it to the screen:    $errinfo = $pdo->errorInfo();    die("SQL ERROR: {$errinfo[2]}");}    // Provide a function that connects to the database for us:function blog_connect() {    // Open the database:    if (!($pdo = new PDO('sqlite:blog.db'))) {        blog_error($pdo);    }        // Return the connection    return $pdo;}// A function that will do queries for us, taking care of error trappingfunction blog_query($pdo, $sql) {    // Run the query:    if (!($results = $pdo->query($sql))) {        blog_error($pdo);    }    // Return the results    return $results;}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?