Home >Backend Development >PHP Tutorial >PHP 传参数 字符串 语法错误
php 数据库
我在看别人代码,发现传参数 和 字符串中的 单双 引号比较困难// 第一个$database = new AAAA([ 'database_type' => 'mysql', 'database_name' => 'web_paris_station', 'server' => 'localhost', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL],]);// 第二个$datas = $database->insert("sell", [ "brand" => $_POST['brand'], "style" => $_POST['style'], "price" => $_POST['price'], "condition" => $_POST['condition'], "description" => $_POST['description'], 'image' => "upload/" . $_FILES["file"]["name"] ]);// 第三个$datas = $database->select( "user", ["*"], ["where" => "email = ".$_POST['email']] );
class AAAA{ protected $database_type = 'mysql'; // For MySQL, MSSQL, Sybase protected $server = 'localhost'; protected $username = 'username'; protected $password = 'password'; // For SQLite protected $database_file = ''; // Optional protected $charset = 'utf8'; protected $database_name = ''; protected $option = array(); public function __construct($options) { } public function query($query) { } public function exec($query) { } public function quote($string) { } protected function array_quote($array) { } protected function data_implode($data, $conjunctor, $outer_conjunctor = null) { } public function where_clause($where) { } public function select($table, $columns, $where = null) { } public function insert($table, $data) { } public function update($table, $data, $where = null) { } public function delete($table, $where) { } public function replace($table, $columns, $search = null, $replace = null, $where = null) { } public function get($table, $columns, $where = null) { } public function has($table, $where) { } public function count($table, $where = null) { } public function max($table, $column, $where = null) { } public function min($table, $column, $where = null) { } public function avg($table, $column, $where = null) { } public function sum($table, $column, $where = null) { } public function error() { } public function last_query() { } public function info() { }}
将 array() 简写成 [] 是 php5.4 才有的功能
1.升级PHP版本到5.4
2.将所有[] 改成 array()