This is a quick tutorial on how to automatically include a path in every php file that you create. This does not mean that you no longer need to do an include:
I just cleared things up. Since that was my assumption when I first learned that I can explicitly include paths in every php file that I create without actually including it.
Things you’ll need
Things to do
First you have to launch wampserver, then right left click on the tray icon >php>php.ini
Open the file using a text-editor if windows prompts you what program should you use to open the file.
After the file has been opened. Press ctrl + H on your keyboard then type include_path, click on find next until you see the windows word right above the word include_path.
Uncomment the line by removing the semicolon before it:
; Windows: "path1;path2" include_path = ".;C:php_includeshome_made"
If you want to include multiple paths then you can separate them using a semicolon, like the example that has already been given just above the include path.
The path that I included contains php classes that I could use for login, connecting to mysql database, sessions, and formatting strings and dates:
Save the file and restart all services from the wampserver tray icon.
All you have to do now is to include those files inside the files where you need them:
It’s a bit easier when you include it using the full path isn’t it?
Don’t forget to declare an object of the class if it’s a class that you are trying to include.
$sessions = new sessions();
That’s it for this quick tutorial. Just make sure that the paths that you included exists, and that the files that you have included exists in the included path. Because you will get a nasty error on every page if the path doesn’t exist.