Reputation: 137
I'm developping a website using MAMP and it is currently live on some Apache server, and working fine. However, a friend of mine copied the whole thing in the root directory of his WAMP server and on his machine, no relative path work (no includes, no images).
The website is developped with the MVC architecture. My friend copied the three folders (M,V and C) and the index.php into the root folder of WAMP (www).
In index.php you have for example the line "include (Modele/conexionBDD.php)" however the server says "no such file or directory in C:\wamp\www\index.php"
Any idea why?
Thanks in advance, Aurélie
Upvotes: 1
Views: 374
Reputation: 94662
This include should work just fine
include (Modele/conexionBDD.php);
but should it not have the parameter in quotes?
include ('Modele/conexionBDD.php');
as PHP does the directory seperator changes for you. In fact it suggests you stick to the unix seperator when coding on Windows.
I realise you may have been using shorthand My friend copied the three folders (M,V and C) and the index.php
but if your friend copied the subfolder Modele
into M
that may explain the issue.
Upvotes: 0
Reputation: 28795
Windows and UNIX (OSX) use different directory separators - hard to believe I know, but Windows uses \
while UNIX uses /
.
In PHP, the OS-specific directory separator is stored as the constant DIRECTORY_SEPARATOR
. Try rewriting the path as:
include('Modele' . DIRECTORY_SEPARATOR . '/conexionBDD.php');
This path should now work on both OS's, but you will probably need to change all paths referenced.
Upvotes: 1