Make reasonable use of cached files

Source: Internet
Author: User

Don't take it all for granted when you want to give tens of thousands of hundreds stadiums users a message to show.

Would you go to the table of information in the database to insert a message to all users?

I think most people don't do that, but sometimes they take it for granted, and that's the way it's done. 20 of them must have done the same.

This is a mistake. A change of mind, to a person is certainly only to 20 users of one of the people only let him see, so we in the library to give him a message, show him to see himself.

For everyone to see the common information, there is no distinction between, then we can generate a cache file, the content to be displayed in the header of the file contains, read static information. You can set the display time in the display, so that you can do not show the expiration.

These are some of the thoughts I learned today, and I think most people are smarter than me.

Here is an example showing:

$arr is the message you're going to show here is an array var_export we all know what to do, not much to do with the narrative.

Because of the PHP file generated, our <?php?> (recommended long mark) is essential.

$array = "<?php\r\nreturn". Var_export ($arr, true). "; R\n?> ";

$path is the address that the cache file is stored in. $file is the file name

$path = $path. $file. " PHP ';

File_put_contents () generates a cache file.

File_put_contents ($path, $array);

It is a good way to get familiar with the business and to improve the logic of thinking by looking at more programs and practicing and optimizing them.

2014-11-18

From Baidu Space Transfer original 1

Make reasonable use of cached files

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.