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
php:php [2016/04/06 08:15] โ€“ [PHP connect Database] adminphp:php [2022/10/29 16:15] (current) โ€“ external edit 127.0.0.1
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 51: Line 51:
 [www] [www]
 catch_workers_output = yes catch_workers_output = yes
 +</code>
 +  * in php.ini:<code ini>
 +display_errors = On โ‡’ Allow display debug information in front end
 </code> </code>
 Config turn on/off log in httpd: Config turn on/off log in httpd:
Line 134: Line 137:
   * Debug with Internet Explorer: Turn on Debug Mode in Internet Options for debugging code javascript error   * Debug with Internet Explorer: Turn on Debug Mode in Internet Options for debugging code javascript error
   * Debug in Chrome: Using Developer Tools for debugging Javascript with break points   * Debug in Chrome: Using Developer Tools for debugging Javascript with break points
 +===== PHPUnit =====
 +refer: https://phpunit.de/getting-started/phpunit-5.html
 +==== Install PHPUnit ====
 +  * Install as binary<code bash>
 +wget -O phpunit https://phar.phpunit.de/phpunit-5.phar
 +chmod +x phpunit
 +./phpunit --version
 +</code>
 +  * Install with composer:<code bash>
 +composer require --dev phpunit/phpunit ^5
 +./vendor/bin/phpunit --version
 +</code>
 +==== Run PHPUnit ====
 ===== PHP Slow Log Config ===== ===== PHP Slow Log Config =====
 ==== Config Slow Log in php-fpm ==== ==== Config Slow Log in php-fpm ====
Line 381: Line 397:
 'client_encoding'    => 'mysqli_client_encoding', 'client_encoding'    => 'mysqli_client_encoding',
 'ping'               => 'mysqli_ping', 'ping'               => 'mysqli_ping',
 +</code>
 +==== Convert from mysql to mysqli ====
 +Using tool: https://github.com/philip/MySQLConverterTool
 +<code bash>
 +php MySQLConverterTool-master/cli.php -f changeusername.php > changeusername_new.php
 +</code>
 +And Modify some missing in tool:<code php>
 +mysqli_connect("127.0.0.1", "forum_ttb", "xxxxxxxxxx"));
 +</code>to<code php>
 +=> 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.1459930536.txt.gz ยท Last modified: 2022/10/29 16:15 (external edit)