At my job, we have multiple people working on a website for a client.
Most of us use macs to do this and our server is running apache on BSD.
In order for us to view our work on our local machines as well as on our dev server (also a mac) I need to have some code that can automatically determine the path to the include directory where the site's configuration file lives.
locally on our machines we would look at the site at: http://127.0.0.1/~user/domain (files in the user's ~/Sites directory)
the dev server on http://devserver/doman (files in /Library/WebServer/Documents)
the production server on http://www.domain.com/ (files in /home/web/sites/domain)
the following code SEEMS to handle this ... buy studying the path and looking to see if Library or Users exists in the path (then it is local or dev) and if not, then it is the live server.
$uri = explode("/", $_SERVER['PATH_TRANSLATED']); $path_site = "http://".$_SERVER['HTTP_HOST'].(ereg('Library|Users', $uri) ? ($uri == "Sites" ? "/~$uri/".$uri[(array_search($site,$uri))] : "/".$uri[(array_search($site,$uri))]) : ((array_search($site,$uri)) > 4 ? "/".$uri[(array_search($site,$uri))] : ""));
However, I am getting the following error in the php errorlog ONLY on the live server:
[Thu Jul 6 13:00:02 2006] [error] PHP Warning: array_search() [<a href='function.array-search'>function.array-search</a>]: Wrong datatype for second argument in /home/web/sites/domain/include/config.php on line 46
Can anyone tell me what I am doing wrong, or even if I should worry about this error? The sites work just fine on all machines so it looks like it is working but I do not like error messages.
can anyone offer a better way to do this? if my way is flawed?
thanks in advance