Home >Backend Development >PHP Tutorial >pretty rhythm dear my future PHP reference file skills
We know that java has the concept of package, while .NET has the more convenient concept of DLL assembly reference. Through these collections of objects combined in packaged form, we can easily reference other objects in our own classes. Classes or other objects defined in other places, but since there is no corresponding concept in PHP, when needing to reference objects defined in other files, the two most commonly used functions by PHP programmers are require_once and include. Through these two functions , we can use objects such as classes defined in other class libraries. But many people simply use the following code to reference files when including other files in the same directory:
Copy the code The code is as follows:
include('include.php');
Copy the code The code is as follows:
include(realpath(dirname(_FILE_)).DIRECTORY_SEPARATOR.' include.php');
Copy the code The code is as follows:
define('APP_PATH',realpath (dirname(_FILE_)));
Copy the code The code is as follows:
include(APP_PATH.DIRECTORY_SEPARATOR.'models'.'User.php');
The above introduces pretty rhythm dear my future PHP file reference techniques, including pretty rhythm dear my future content. I hope it will be helpful to friends who are interested in PHP tutorials.