<?php
include 'libs/mysql.php';
include 'libs/mysqli.php';
include 'libs/pdo.php';
include 'libs/file.php';
include 'libs/constants.php';
include 'libs/functions.php';
$mysql = new \Includes\Code\Mysql();
$mysqli = new \Includes\Code\Mysqli();
$pdo = new \Includes\Code\Pdo();
$file = new \Includes\Code\File();
echo \Includes\Code\getSql() . '<br>';
echo \Includes\Code\saveSql('select * from abc') . '<br>';
echo \Includes\Code\DB_USER . '<br>';
echo \Includes\Code\DB_PWD . '<br>';
可读性高的写法(简明许多):
注意:PHP 5.6.0发布 use关键字可导入函数与常量
<?php
include 'libs/mysql.php';
include 'libs/mysqli.php';
include 'libs/pdo.php';
include 'libs/file.php';
include 'libs/constants.php';
include 'libs/functions.php';
use Includes\Code\Mysql;
use Includes\Code\Mysqli;
use Includes\Code\Pdo;
use Includes\Code\File;
use function Includes\Code\saveSql;
use function Includes\Code\getSql;
use const Includes\Code\DB_USER;
use const Includes\Code\DB_PWD;
$mysql = new Mysql();
$mysqli = new Mysqli();
$pdo = new File();
$file = new File();
echo getSql() . '<br>';
echo saveSql('select * from abc') . '<br>';
echo DB_USER . '<br>';
echo DB_PWD . '<br>';