I want to implement a function, because every time the system I use is updated, it will overwrite the piece of code I added myself.
I want to implement this function. If it covers my code, I will open that piece of code. Add it again.
This is this code. If it is covered, I will open this file php file, framework/bootstrap.inc.php
And search for this part, ['development'] == 1);
The complete thing is like thisdefine('DEVELOPMENT', $_W['config'] ['setting']['development'] == 1);
If true is returned after search, then a new line is added and a piece of code is appended after it
Like this
After search.
`define('DEVELOPMENT', $_W['config']['setting']['development'] == 1);`
// 追加的代码
define('DEBUG', $_W['config']['setting']['debug'] == 1);
if(DEBUG){
include ROOT.'/framework/debug.php';
}
Why not find the problem that some code will be overwritten when updating the code, but solve the problem in this roundabout way?
Why not
Create a separate file for this code you added, and then load both the system update file and your file into it
In this way, you don’t have to worry about it being overwritten by the system after updating, and it is much easier to maintain your own code.
I agree with the point above. But if you have to do this, you can add a comment to the code you added. Then read the contents of the entire file and use comments to split the file into two strings. Then concatenate your code with the two strings, and finally write it to the file.