Can PHP load a database for permanent use at a time, such as a database? almost all pages call it. is there a way for PHP to call it; you don't need to require it on every page. & nbsp; the premise is that this is a function library. & nbsp; in fact, no code is executed every time you load it. can PHP load the database once for permanent use?
For example, if a library is called on almost all pages, is there a way to call it without having to require it on every page, provided that this function is a function library and no code is executed every time it is loaded.
------ Solution --------------------
Reference:
For example, if a library is called on almost all pages, is there a way to call it without having to require it on every page, provided that this function is a function library and no code is executed every time it is loaded.
Referencing a file is the principle of always inheriting from top to bottom. Assume that a is your global file. When B references a and c references B, a is also referenced. E. If B is not referenced, you need to reference a by yourself.
There are three methods to implement the method you mentioned:
1. design the system as a single portal. each time a global file is loaded at the entrance, your global file will be referenced by the Portal file. You can refer to the mvc framework design method.
Portal File-> bootstrap-> front_controller-> router mapping-> controller
-> Controller B
-> Controller c
Reference your global file in bootstrap.
2. implement autoload, so that when your instance has a class that does not currently exist, it will automatically load that file.
3. write your database as a php extension. the extension of php will automatically load and remain in the process when the php process starts.
------ Solution --------------------
Supplemental upstairs
4. php. ini automatically loads files. For more information, see auto_prepend_file and auto_append_file. pay attention to global issues such as session.
5. automatically load web servers. For more information, see Server documentation.
6. automatic system loading. refer to the system documentation.
------ Solution --------------------
If you can successfully install the apc extension, it will cache some code in the memory, instead of having to multiple files each time.
There was an eAccelerator extension that worked well, but php5.3 won't work anymore.
As for apc expansion, it has never been loaded successfully. So I don't know if it works as he said.
------ Solution --------------------
Reference:
If you can successfully install the apc extension, it will cache some code in the memory, instead of having to multiple files each time.
There was an eAccelerator extension that worked well, but php5.3 won't work anymore.
As for apc expansion, it has never been loaded successfully. So I don't know if it works as he said.
Well, after 5.x, we started to use apc. yes. I don't feel as obvious as eAccelerator, but it may be a psychological effect.
------ Solution --------------------
I have been thinking about this title for a long time, but I don't understand it.
------ Solution --------------------
Traverse the project file, store the file path in a file, serialize the file, set an expiration time, and read the file directly from the serialized file each time, you can refer to the php automatic file loading function spl_autoload_register ().
------ Solution --------------------
Reference:
Reference: I have been thinking about this title for a long time. I don't understand this title.
As a matter of fact, the system is optimized to read files frequently. if files are loaded frequently from the disk, the speed is intolerable and the data is stored in the memory, therefore, when reading the same file for multiple times, the file size is not very large. if the memory is enough, the speed is very fast.
But even so, it is still a problem to reload a large page ,......
The APC mentioned above
------ Solution --------------------