微信支付配置文件WxPay.Config.php如何读取数据库配置信息
问一下大神怎么解决的这个问题
抄来的 不求最佳 只是希望对你有帮助
require_once("././././config.php");
require_once(SYSTEM."db.php"); //导入db类
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);//实例化db
$sql = "SELECT * FROM setting ";
$query = $db->query($sql);
$rows = $query->rows;
$appid = '5';
$mchid = '1';
$key = 'a';
$appsecret = 'c';
$sslcert_path = 'apiclient_cert.pem';
$sslkey_path = 'apiclient_key.pem';
$curl_proxy_host = '0.0.0.0';
$curl_proxy_port = 0;
$report_levenl = 1;
$config = "
class WxPayConfig
{
const APPID = '$appid';
const MCHID = '$mchid';
const KEY = '$key';
const APPSECRET = '$appsecret';
const SSLCERT_PATH = '$sslcert_path';
const SSLKEY_PATH = '$sslkey_path';
const CURL_PROXY_HOST = '$curl_proxy_host';//'10.152.18.220';
const CURL_PROXY_PORT = $curl_proxy_port;//8080;
const REPORT_LEVENL = $report_levenl;
}
";
eval($config);
unset($config, $appid, $mchid, $key, $appsecret, $sslcert_path, $sslkey_path, $curl_proxy_host, $curl_proxy_port, $report_levenl);
//echo WxPayConfig::APPID;exit;
//不清楚可以问联系我:web$ebaitian.cn(将$换为@)
require_once("././././config.php");
require_once(SYSTEM."db.php"); //导入db类
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);//实例化db
$sql = "SELECT * FROM setting ";
$query = $db->query($sql);
$rows = $query->rows;
$appid = '5';
$mchid = '1';
$key = 'a';
$appsecret = 'c';
$sslcert_path = 'apiclient_cert.pem';
$sslkey_path = 'apiclient_key.pem';
$curl_proxy_host = '0.0.0.0';
$curl_proxy_port = 0;
$report_levenl = 1;
$config = "
class WxPayConfig
{
const APPID = '$appid';
const MCHID = '$mchid';
const KEY = '$key';
const APPSECRET = '$appsecret';
const SSLCERT_PATH = '$sslcert_path';
const SSLKEY_PATH = '$sslkey_path';
const CURL_PROXY_HOST = '$curl_proxy_host';//'10.152.18.220';
const CURL_PROXY_PORT = $curl_proxy_port;//8080;
const REPORT_LEVENL = $report_levenl;
}
";
eval($config);
unset($config, $appid, $mchid, $key, $appsecret, $sslcert_path, $sslkey_path, $curl_proxy_host, $curl_proxy_port, $report_levenl);
//echo WxPayConfig::APPID;exit;
//不清楚可以问联系我:web$ebaitian.cn(将$换为@)
温馨提示:答案为网友推荐,仅供参考
第1个回答 2016-08-19
使用php开发微信支付,所填写的配置信息,最好还是写在配置文件里,不要写在数据库里,如果是要操作两个公众号,你可以在配置文件里,创建两份资料,然后在声明类时更具需要把相关公众号的资料配置进去
第2个回答 2016-07-26
require_once("././././config.php");
require_once(SYSTEM."db.php"); //导入db类
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);//实例化db
$sql = "SELECT * FROM setting ";
$query = $db->query($sql);
$rows = $query->rows;
$appid = '5';
$mchid = '1';
$key = 'a';
$appsecret = 'c';
$sslcert_path = 'apiclient_cert.pem';
$sslkey_path = 'apiclient_key.pem';
$curl_proxy_host = '0.0.0.0';
$curl_proxy_port = 0;
$report_levenl = 1;
$config = "
class WxPayConfig
{
const APPID = '$appid';
const MCHID = '$mchid';
const KEY = '$key';
const APPSECRET = '$appsecret';
const SSLCERT_PATH = '$sslcert_path';
const SSLKEY_PATH = '$sslkey_path';
const CURL_PROXY_HOST = '$curl_proxy_host';//'10.152.18.220';
const CURL_PROXY_PORT = $curl_proxy_port;//8080;
const REPORT_LEVENL = $report_levenl;
}
";
eval($config);
unset($config, $appid, $mchid, $key, $appsecret, $sslcert_path, $sslkey_path, $curl_proxy_host, $curl_proxy_port, $report_levenl);
//echo WxPayConfig::APPID;exit;
//不清楚可以问联系我:web$ebaitian.cn(将$换为@)
require_once(SYSTEM."db.php"); //导入db类
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);//实例化db
$sql = "SELECT * FROM setting ";
$query = $db->query($sql);
$rows = $query->rows;
$appid = '5';
$mchid = '1';
$key = 'a';
$appsecret = 'c';
$sslcert_path = 'apiclient_cert.pem';
$sslkey_path = 'apiclient_key.pem';
$curl_proxy_host = '0.0.0.0';
$curl_proxy_port = 0;
$report_levenl = 1;
$config = "
class WxPayConfig
{
const APPID = '$appid';
const MCHID = '$mchid';
const KEY = '$key';
const APPSECRET = '$appsecret';
const SSLCERT_PATH = '$sslcert_path';
const SSLKEY_PATH = '$sslkey_path';
const CURL_PROXY_HOST = '$curl_proxy_host';//'10.152.18.220';
const CURL_PROXY_PORT = $curl_proxy_port;//8080;
const REPORT_LEVENL = $report_levenl;
}
";
eval($config);
unset($config, $appid, $mchid, $key, $appsecret, $sslcert_path, $sslkey_path, $curl_proxy_host, $curl_proxy_port, $report_levenl);
//echo WxPayConfig::APPID;exit;
//不清楚可以问联系我:web$ebaitian.cn(将$换为@)
第3个回答 2016-05-30
你完全可以不去考虑这个文件的,在需要这个文件的地方,读取好数据库中的信息 对应的处理上去就可以了 如果非要用这个文件的话 那就把这个类中的static去掉 就可以使用变量了
第4个回答 2016-06-25
你完全可以不去考虑这个文件的,在需要这个文件的地方,读取好数据库的信息,对应的处理上去就可以了,如果非要用这个文件的话,就把这个类中的static去掉, 就可以使用变量了。