PHP7 installation Redis Extended Tutorial "Linux and Windows platform" _php tips

Source: Internet
Author: User
Tags php programming php regular expression redis

The example in this article describes the PHP7 installation Redis extension method. Share to everyone for your reference, specific as follows:

PHP7 installation Redis extension in Linux

1. Sequentially executes

Wget-c https://github.com/phpredis/phpredis/archive/php7.zip
Unzip php7.zip
CD PHPREDIS-PHP7
/phpize
./configure--with-php-config=/youpath/php-config make make
install

2. Join PHP.ini

3. Restart httpd

4. View probe

WindowsPHP7 installation Redis Extension

This provides a php5.3 version of the Redis PHP expansion Compression Pack (which has a DLL): Https://github.com/nicolasff/phpredis/downloads

After decompression, put the DLL in the EXT directory of PHP, open php.ini, add a line:

Extension=php_redis.dll

and restart Apache.

Example:

 <?php//Get the ID of the voting information $aid = isset ($_get[' aid '])? Ereg_replace ("[^0-9]", "", $_get[' aid '
]): 0;
The current number of votes, referring to the data in the Redis $this _click_num = 0;
 if ($aid >2) {//Set the maximum number of votes to write back, write back to the mysql $update _till_num = 50;
 Create a Redis object $r = new Redis ();
 $r->connect (' 127.0.0.1 ', 6379);
 Get now is the first few data $this _click_num = $r->get (' count_xin_newgame: '. $aid);
 Click on the number plus 1 $r->set (' count_xin_newgame: '. $aid, $this _click_num+1);
 if ($this _click_num>= $update _till_num) {//If the number of clicks exceeds the set number, write the data to the MySQL if ($this _click_num> $update _till_num) Require_once (DirName (__file__). "
 /db.php "); Update Database $db->executenonequery ("Update" Addonnewgame ' SET ' game_num ' = Game_num + ' {$update _till_num} ' WHERE ' de
 De_addonnewgame '. ' Aid ' ={$aid}; ");
 The number of reset votes was 0 $r->set (' count_xin_newgame: '. $aid, 0);
 } $r->settimeout (' count_xin_newgame: '. $aid, 7*24*60*60);
Exit ($this _click_num); }?> 

More about PHP Interested readers can view the site topics: "PHP Expanded Development course", "PHP object-oriented Program Design Introductory Course", "PHP Mathematical Calculation Skills Summary", "PHP Array" operation Skills Encyclopedia, "PHP Data structure and algorithm tutorial", " PHP Programming algorithm Summary, "PHP Regular Expression Usage summary" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.