How to save the resource in our project code? Should we repeat writing the same code in every page/file? We can save a lot of our time and resource by putting the same code or lines into a function or procedure.
In some programming language, such as Pascal, Batch, C, PHP, etc., we can make a single special file where we can store our functions and procedure, also some constant.
Files which stored functions and procedures generally called “library“. The reason? coz it store many functions… I don’t know the other reasons..
For some constant (variables that store fixed value), we can put it on a editable file, like “config.php” in PHP or “config.tpu” in Pascal. So if we need some constant, we only need to call that file.
For example, we have some web pages that require same coding and data, but in different web design, should we write the same codes in every page? and how if there’s a minor change in the codes? it will make us work on those page again.
We can solve that problem by creating a single file that contain the function, and call the function from every page. So, if there’s any change on the code, we have to modify the file that contain the function only. In PHP, you can also include the file with “include()” function rather than calling for the function.