"Best" way to include files | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

"Best" way to include files

How to include (require) files so that it is the least dependent of the position of the include in question :) For example: How to include header file in various different files? Is only bad thing about using full path that it would be harder to change from linux to windows (for example)? P.S. First post :)

12th May 2017, 2:01 PM
Slon
2 Respostas
+ 1
Make a config.inc.php file. put all of your long paths in it. in your layout files instead of passing loooong paths. pass variable from config.inc.php P.S. you can give any name to your config file. just don't forget the ".php" at the end šŸ˜‚šŸ˜‚šŸ˜‚
15th May 2017, 9:31 PM
Abdullah Mallik @mdn522
Abdullah Mallik @mdn522 - avatar
0
Thanks :) I already did it like that, though without .inc part :) Made a Locations class and const array in it with full paths for values and short description for keys.
15th May 2017, 10:24 PM
Slon