Tag Archives | PHP

Function apache_request_headers on Nginx

Function apache_request_headers supports only on Apache, how to use it on Nginx. Here is the solution:

Read full story Comments { 0 }

PHP: Example of usage CURLOPT_WRITEFUNCTION

CURLOPT_WRITEFUNCTION: A callback accepting two parameters. The first is the cURL resource, and the second is a string with the data to be written. The data must be saved by this callback. It must return the exact number of bytes written or the transfer will be aborted with an error. Result: Example 2:

Read full story Comments { 0 }

PHP: Example of usage CURLOPT_HEADERFUNCTION

If you set option CURLINFO_HEADER_OUT to true, you can get request header with function curl_getinfo (see example 2) CURLOPT_HEADERFUNCTION: A callback accepting two parameters. The first is the cURL resource, the second is a string with the header data to be written. The header data must be written by this callback. Return the number of […]

Read full story Comments { 0 }

RC4 implementation in PHP and Javascript

In cryptography, RC4 (Rivest Cipher 4 also known as ARC4 or ARCFOUR meaning Alleged RC4, see below) is a stream cipher. We provide some function RC4 in PHP and Javascript PHP: JS: Example: Result: Try it yourself Some RC4 variants RC4A cipher implement in PHP and Javascript VMPC stream cipher implement in PHP and Javascript […]

Read full story Comments { 0 }

PHP function ord of unicode character

PHP have function ord to find ASCII value of character. But PHP don’t support a function to find this value of unicode character. Now, we provider some method: Examples:

Read full story Comments { 0 }
Edge detection with PHP

Edge detection with PHP

We do some example with this image : http://static.asiawebdirect.com/m/bangkok/portals/vietnam/homepage/hanoi/pagePropertiesImage/hanoi-guide.jpg Method 1: Online demo: Method 2: Use imagefilter: Online demo: Method 3: Online demo: Method 4: use imageconvolution Online demo: Please comment the mothod you prefer.

Read full story Comments { 0 }
How to create transparent image with PHP

How to create transparent image with PHP

Method 1: use imagecolorallocatealpha and imagesavealpha Online demo: Method 2: use imagecolortransparent Online demo:

Read full story Comments { 0 }

PHP: how to fix the error: Warning: session_start() failed: No such file or directory

If you get the error like: How to fix it? It’s simple, you must only edit file php.ini Step 1: Open file php.ini Step 2: Find the line Ex: Step 3: Change to the correct path Ex: Step 4: restart Apache Done

Read full story Comments { 0 }

How to detect AJAX request in PHP

Here are some quick PHP snippets that you can use to detect AJAX request in PHP: Method 1: We use the function apache_request_headers to detect AJAX request in PHP Note: $request_headers will have the value like: Method 2: Use the variable $_SERVER Note: $_SERVER will have the value like:

Read full story Comments { 0 }

How to install GeoIp module for PHP

How to install GeoIp module for PHP on Windows Step 1: Download GeoIP release at here Ex: for PHP 5.4 http://windows.php.net/downloads/pecl/releases/geoip/1.0.8/php_geoip-1.0.8-5.4-ts-vc9-x86.zip Step 2: extract file php_geoip.dll then place it in your extension folder like: D:\AppServ\php5\ext Step 3: Download file GeoLiteCity.dat.gz Step 4: extract file GeoLiteCity.dat and rename it to GeoIPCity.dat Step 5: Place this file […]

Read full story Comments { 1 }