500 - php curl_exec()方法 報500錯誤
Jul 06, 2016 pm 01:52 PM
最近在用做商城的微信掃碼支付功能時,在代碼構(gòu)建微信訂單然后通過curl向微信請求的時候,curl_exec函數(shù)報500錯誤,且沒有詳細的錯誤信息給出。之前用阿里云服務(wù)器、我的本地測試時,均無問題,因為客戶需要現(xiàn)在程序放在了阿里云的虛擬主機上,就出現(xiàn)這個問題了,并且我確認curl已開啟可以用,錯誤顯示display_errors和error_reporting也已經(jīng)設(shè)置成顯示所有錯誤。但:
1、只顯示500錯誤,不顯示任何詳細的錯誤信息。
2、該主機只能看到訪問日志,無法看到錯誤日志,也無法看到和修改php.ini設(shè)置和apache設(shè)置等。
3、利用@、try catch也無法使這個錯誤跳過,并且curl的資源參數(shù)也是正確的(我每個參數(shù)都打印過)
綜上所述,我仍未找到方法定位這個錯誤,希望大神指導(dǎo)指導(dǎo)。
<code> $ch = curl_init(); //設(shè)置超時 curl_setopt($ch, CURLOPT_TIMEOUT, $second); //如果有配置代理這里就設(shè)置代理 if(WxPayConfig::getValue('curl_proxy_host') != "0.0.0.0" && WxPayConfig::getValue('curl_proxy_port') != 0){ curl_setopt($ch,CURLOPT_PROXY, WxPayConfig::getValue('curl_proxy_host')); curl_setopt($ch,CURLOPT_PROXYPORT, WxPayConfig::getValue('curl_proxy_port')); } curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//嚴格校驗 //設(shè)置header curl_setopt($ch, CURLOPT_HEADER, FALSE); //要求結(jié)果為字符串且輸出到屏幕上 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); if($useCert == true){ //設(shè)置證書 //使用證書:cert 與 key 分別屬于兩個.pem文件 curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM'); curl_setopt($ch,CURLOPT_SSLCERT, WxPayConfig::getValue('sslcert_path')); curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); curl_setopt($ch,CURLOPT_SSLKEY, WxPayConfig::getValue('sslkey_path')); } //post提交方式 curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); //運行curl $data = curl_exec($ch); //返回結(jié)果 if($data){ curl_close($ch); return $data; } else { $error = curl_errno($ch); curl_close($ch); throw new WxPayException("curl出錯,錯誤碼:$error"); }</code>
回復(fù)內(nèi)容:
最近在用做商城的微信掃碼支付功能時,在代碼構(gòu)建微信訂單然后通過curl向微信請求的時候,curl_exec函數(shù)報500錯誤,且沒有詳細的錯誤信息給出。之前用阿里云服務(wù)器、我的本地測試時,均無問題,因為客戶需要現(xiàn)在程序放在了阿里云的虛擬主機上,就出現(xiàn)這個問題了,并且我確認curl已開啟可以用,錯誤顯示display_errors和error_reporting也已經(jīng)設(shè)置成顯示所有錯誤。但:
1、只顯示500錯誤,不顯示任何詳細的錯誤信息。
2、該主機只能看到訪問日志,無法看到錯誤日志,也無法看到和修改php.ini設(shè)置和apache設(shè)置等。
3、利用@、try catch也無法使這個錯誤跳過,并且curl的資源參數(shù)也是正確的(我每個參數(shù)都打印過)
綜上所述,我仍未找到方法定位這個錯誤,希望大神指導(dǎo)指導(dǎo)。
<code> $ch = curl_init(); //設(shè)置超時 curl_setopt($ch, CURLOPT_TIMEOUT, $second); //如果有配置代理這里就設(shè)置代理 if(WxPayConfig::getValue('curl_proxy_host') != "0.0.0.0" && WxPayConfig::getValue('curl_proxy_port') != 0){ curl_setopt($ch,CURLOPT_PROXY, WxPayConfig::getValue('curl_proxy_host')); curl_setopt($ch,CURLOPT_PROXYPORT, WxPayConfig::getValue('curl_proxy_port')); } curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//嚴格校驗 //設(shè)置header curl_setopt($ch, CURLOPT_HEADER, FALSE); //要求結(jié)果為字符串且輸出到屏幕上 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); if($useCert == true){ //設(shè)置證書 //使用證書:cert 與 key 分別屬于兩個.pem文件 curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM'); curl_setopt($ch,CURLOPT_SSLCERT, WxPayConfig::getValue('sslcert_path')); curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); curl_setopt($ch,CURLOPT_SSLKEY, WxPayConfig::getValue('sslkey_path')); } //post提交方式 curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); //運行curl $data = curl_exec($ch); //返回結(jié)果 if($data){ curl_close($ch); return $data; } else { $error = curl_errno($ch); curl_close($ch); throw new WxPayException("curl出錯,錯誤碼:$error"); }</code>
一般來說虛擬主機會讓你看錯誤日志的,不過可能是最后的多少條。
我猜想可能是超出內(nèi)存限制了吧,你提交工單問問。
何不貼代碼?
在php文件最開始加入以下代碼:
<code>set_error_handler(function(){ echo '<pre class="brush:php;toolbar:false">'; var_dump(func_get_args()); debug_print_backtrace(); },E_ERROR); set_error_handler(function(\Exception $e){ echo '<pre class="brush:php;toolbar:false">'; echo $e->getFile().PHP_EOL; echo $e->getLine().PHP_EOL; echo $e->getMessage().PHP_EOL; echo $e->getTraceAsString().PHP_EOL; });

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











PHP?? ?? ?? ID? ?? ??? Session_id () ??? ???? ???? Session_Start ()? ???? ????? ??????. 1. ??? ????? ?? _start ()? ?????. 2. Session_id ()? ???? ?? ID? ?? ABC123DEF456GHI789? ??? ???? ?????. 3. ??? ?? ??? Session_Start ()? ??????, ???? ???? ?????? ?? ??? ?????? ??? ??????. 4. ?? ID? ??, ?? ?? ? ?? ?? ??? ??? ? ??? ?????? ???????. ??? ???? ????? ID? ????? ?? ? ??? ??????.

PHP ????? ?? ???? ????? Syntax substr (String $ String, int $ start,? int $ length = null) ? substr () ??? ??? ? ??? ??? ???? ??? ??? ?????. ???? ?? ?? ??? ??? ?? ? ?? MB_SUBSTR () ??? ???? ?? ??? ??????. ?? ???? ?? ???? ?? ????? ?? exploit () ?? strtr ()? ???? ?? ?? ??? ?? ??? ?? ??? ?? ??? ? ????.

UnitTestingInphPinvolvesVeverifying individualCodeUnitsInitsIntsormeStodStocatchBugSearlyLylyLearLiAberFactoring.1) setupphPunitviacomposer, createEatestDirectory, and ConfigeAuteAutoloadandPhpunit.xml.2) writeTestCases-oct-oct-asserterfat

PHP?? ?? ???? ??? exploit () ??? ???? ???? ??? ???? ????. ? ??? ??? ?? ??? ?? ???? ?? ???? ??? ??? ?????. ??? Exploit (???, ???, ??)??, ??? ???? ????? ???? ?? ?????, ??? ????? ?? ?? ?????? ??? ?? ?????. ?? ?? $ str = "Apple, Banana, Orange"; $ arr = Explode ( ",", $ str); ??? [ "Apple", "Bana???

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

STD :: Chrono? ?? ?? ??, ?? ?? ??, ?? ?? ? ?? ?? ? ?? ?? ??? ???? C?? ???? ??? ?????. 1. std :: chrono :: system_clock :: now ()? ???? ?? ??? ?? ? ??? ?? ??? ???? ?? ? ? ??? ??? ??? ???? ?? ?? ? ????. 2. std :: Chrono :: steady_clock? ???? ?? ??? ???? ?? ??? ???? duration_cast? ?? ?? ?, ? ? ?? ??? ??????. 3. ?? (time_point) ? ?? (??)? ?? ??? ? ? ??? ?? ??? ? ?? epoch (epoch)???? ???????.

PHP?? ?? ??? ?? ???? ????? ?? ??? ???? ???? ??? $ _session ? ??? ???? ????. 1. ? ???? ?? ??? ???? ?? Session_Start ()? ???? ???? ??? ???????. 2. $ _session [ 'username'] = 'johndoe'? ?? ?? ??? ?????. 3. ?? ????? session_start ()? ?? ? ? ??? ? ??? ?? ??? ???????. 4. Session_Start ()? ? ????? ???? ??? ????, ???? ?? ???? ??, ??? ?? ???? ??? ?? ? ? ??? ??????. 5. SES? ??????

toaccessenvironmentvariablesinphp, usegetenv () ?? $ _envsuperglobal.1.getenv ( 'var_name') retrievespescificvariable.2. $ _ en v [ 'var_name'] accessesvariablesifvariables_orderinphp.iniincludes "e".setvariablesviacliwithvar = valuephpscript.php, inapach
