PHP: how to convert ip address to binary string or hex string

hex2ip

With pure PHP, you can convert an IPv4 address to long with the function ip2long, but how to convert an Ipv6 address to long. You can't do this in the 32bits system. You only convert an ip address to binary string or hex string with some method we provide below: <?php /** * @author www.tutorialspots.com * @copyright 2016 **/ function ip2bin($ip)...

PHP function ord of unicode character

unicode ord

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: <?php /** * @author www.Tutorialspots.com * @copyright 2015 */ function unicodeord($c) { $t = mb_convert_encoding($c, 'UCS-2LE', 'UTF-8'); return (ord($t{1}) << 8) + ord($t{0}); } function unicodeord2($c) { ...

PHP: Google translate token

<?php /* Copyright: www.tutorialspots.com */ //Unsigned right shift function uRShift($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a >> 1); $a &= ( ~ $z); $a |= 0x40000000; ...

How to install Chilkat PHP on Linux

In this tutorial, i use PHP 5.4 and CentOS 32bits. Step 1: You can find other download at here For 32bits wget http://chilkatdownload.com/9.5.0.63/chilkat-9.5.0-php-5.4-x86-linux.tar.gz For 64bits wget http://chilkatdownload.com/9.5.0.63/chilkat-9.5.0-php-5.4-x86_64-linux.tar.gz Result: # wget http://chilkatdownload.com/9.5.0.63/chilkat-9.5.0-php- 5.4-x86-linux.tar.gz --2016-12-22 13:08:32-- http://chilkatdownload.com/9.5.0.63/chilkat-9.5.0-php-5 .4-x86-linux.tar.gz Resolving chilkatdownload.com... 52.216.224.242 Connecting to chilkatdownload.com|52.216.224.242|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 5103383 (4.9M) Saving to: `chilkat-9.5.0-php-5.4-x86-linux.tar.gz' 100% 5,103,383 13.9M/s in 0.3s 2016-12-22 13:08:33 (13.9 MB/s) - `chilkat-9.5.0-php-5.4-x86-linux.tar.gz' saved Step 2:...

How to fix error: Cannot load Zend Extension Manager – it was built with configuration 1.2.0

If you get the error like: Cannot load Zend Extension Manager - it was built with configuration 1.2.0, wher eas running engine is API220100525,NTS You can fix by follow theses steps: Step 1: Log into Kloxo controlpanel like http://111.111.111.111:7778 Step 2: goto PHP config Step 3: disable Zend Click Update. Done.

How to fix error: Failed loading /usr/lib/kloxophp/ioncube/ioncube_loader_lin_5.2.so

If you get the error like: Failed loading /usr/lib/kloxophp/ioncube/ioncube_loader_lin_5.2.so: /usr/lib/kl oxophp/ioncube/ioncube_loader_lin_5.2.so: undefined symbol: php_body_write Cannot load Zend Extension Manager - it was built with configuration 1.2.0, wher eas running engine is API220100525,NTS You can fix by follow theses steps: Step 1: Log into Kloxo controlpanel like http://111.111.111.111:7778 Step 2: goto PHP config Step 3: disable Ioncube Click Update. Done.

Scraping web content by using YQL

The YQL (Yahoo! Query Language) platform enables you to query, filter, and combine data across the web through a single interface. It exposes a SQL-like syntax that is both familiar to developers and expressive enough for getting the right data. Read first: HTML XPath examples Demo web page 1: Example 1: raw XPath select content from html where url="http://demo.tutorialspots.com/html/?html=PGh0bWw%2BPGJvZHk%2BIDxoMT5Mb3JlbSBpcHN1bSBkb2xvciBzaXQgYW1ldDwvaDE%2BIDxwIGlkPSJwMSI%2BTG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gPGEgaHJlZj0iYmxhaC5odG1sIiB0aXRsZT0iQ3JhcyBtYXNzYSBwdXJ1cyI%2BQ3JhcyBtYXNzYSBwdXJ1czwvYT4sIGV1aXNtb2Qgbm9uIGR1aSBlZ2V0LCB1bGxhbWNvcnBlciBjb25zZXF1YXQgYXVndWUuIEZ1c2NlIGVuaW0gc2VtLCBzdXNjaXBpdCBhIG51bGxhIHF1aXMsIHZlc3RpYnVsdW0gZmVybWVudHVtIG51bGxhLjwvcD4gPHAgaWQ9InAyIj5QaGFzZWxsdXMgYWxpcXVhbSBsaWd1bGEgaWQgbWV0dXMgcGVsbGVudGVzcXVlIHVsdHJpY2VzLiBVdCBhbGlxdWFtIG51bGxhIGFudGUsIHZpdGFlIHVsdHJpY2llcyBkdWkgcnV0cnVtIHF1aXMuIDxhIGhyZWY9ImJsYWguaHRtbCIgdGl0bGU9IlN1c3BlbmRpc3NlIHBvdGVudGkiPlN1c3BlbmRpc3NlIHBvdGVudGk8L2E%2BLiBOdW5jIGV1IGhlbmRyZXJpdCBleC48L3A%2BIDwvYm9keT48L2h0bWw%2B" and xpath='/html/body/h1' Result: { "query": { ...

HTML XPath examples

Here are some demo HTML: HTML 1: <html><body> <h1>Lorem ipsum dolor sit amet</h1> <p id="p1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. <a href="blah.html" title="Cras massa purus">Cras massa purus</a>, euismod non dui eget, ullamcorper consequat augue. Fusce enim sem, suscipit a nulla quis, vestibulum fermentum nulla.</p> <p id="p2">Phasellus aliquam ligula id metus pellentesque ultrices. Ut aliquam nulla ante, vitae ultricies dui rutrum quis. <a...

PHP: Solve system of linear equations using matrices

<?php /** * @author www.tutorialspots.com * @base on www.numericjs.com * @copyright 2015 */ class numeric { public static function LU($A) { $n = count($A); $n1 = $n - 1; $P = array(); ...

How to fix error: 504 Gateway Time-out on Nginx

Sometimes, you get the error: 504 Gateway Time-out on Nginx like this figure, how to fix it. This is simple. You follow 2 below steps: Step 1: Add this line to your PHP file set_time_limit(0); or set_time_limit(120); You can change 120 to the seconds you want. Step 2: You edit the file .conf like /etc/nginx/conf.d/default.conf, you will see the content like: server { listen ...