User Tools

Site Tools


php:php

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
php:php [2019/01/23 23:45] – [Config debug mode in PHP] adminphp:php [2019/02/20 06:10] – [Convert from mysql to mysqli] admin
Line 45: Line 45:
   * Explain config:display_errors = On => Allow display debug information in front end   * Explain config:display_errors = On => Allow display debug information in front end
 Config turn on debug log in **ngix with php-fpm backend**: Config turn on debug log in **ngix with php-fpm backend**:
-<code>+  * in php-fpm.conf<code>
 [global] [global]
 error_log = /var/log/php-fpm.log error_log = /var/log/php-fpm.log
Line 52: Line 52:
 catch_workers_output = yes catch_workers_output = yes
 </code> </code>
-in php.ini: display_errors = On ⇒ Allow display debug information in front end+  * in php.ini:<code ini> 
 +display_errors = On ⇒ Allow display debug information in front end 
 +</code>
 Config turn on/off log in httpd: Config turn on/off log in httpd:
   * [/etc/httpd/conf.d/php.conf]<code>   * [/etc/httpd/conf.d/php.conf]<code>
Line 405: Line 407:
 </code>to<code php> </code>to<code php>
 => mysqli_connect("127.0.0.1", "forum_ttb", "xxxxxxxxxx","forum_ttb")); => mysqli_connect("127.0.0.1", "forum_ttb", "xxxxxxxxxx","forum_ttb"));
 +</code>
 +===== PHP curl =====
 +<code php>
 +<?php
 +function curl_post($url, $vars=array(), $second=10)
 +{
 +    try{
 +        $ch = curl_init();
 +        if ($ch === false) {
 +            throw new Exception('failed to initialize');
 +        }
 +        curl_setopt($ch,CURLOPT_TIMEOUT,$second);
 +        curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
 +        curl_setopt($ch,CURLOPT_URL,$url);
 +        curl_setopt($ch,CURLOPT_POST, 1);
 +        curl_setopt($ch,CURLOPT_POSTFIELDS,$vars);
 +        $data = curl_exec($ch);
 +        if ($data === false) {
 +            throw new Exception(curl_error($ch), curl_errno($ch));
 +        }
 +        curl_close($ch);
 +    }catch(Exception $e){
 +        echo "Curl Error: " . $e->getCode . $e->getMessage();
 +    }
 +    if($data)
 +        return $data;
 +    else
 +        return false;
 +}
 </code> </code>
php/php.txt · Last modified: 2022/10/29 16:15 by 127.0.0.1