Re: scandir problem [message #185711 is a reply to message #185703] |
Sat, 03 May 2014 22:11 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Sat, 03 May 2014 12:08:18 -0400, richard wrote:
> On Sat, 3 May 2014 11:43:45 -0400, richard wrote:
>
>> http://www.php.net/manual/en/function.scandir.php
>>
>> Using their method, what is the proper way to insert a variable within
>> the url?
>>
>> e.g.
>> http://www.something.com/dir/$variable
>>
>> Is the ending / needed?
>> this does not work.
>> $dir="http://www.something.com/dir/$variable"
>> $dir="http://www.something.com/dir/".$variable
>
> I did get it working by using the ".." before the path. Apparently, the
> full url method does not work in this case.
The problem that you encountered is not the problem that you stated it
was. Your error[1] was the failure to understand the difference between
an http url and a filesystem path.
The webserver translates the http url to the filesystem path, where the
"root" directory of the webserver "www.something.com" might be at a file
path that looks something like "/users/s/something.com/http/"
For example, on a fasthosts uk server, using apache, the root of the http
files is available as: {$_SERVER["DOCUMENT_ROOT"]}
Your problem is that you were trying to use a url as a filepath.
What you need to do is take the url:
http://www.something.com/dir/
replace the part: "http://www.something.com" with "{$_SERVER
["DOCUMENT_ROOT"]}"
then append the path part of the url: "/dir/"
then append your $variable
To generate:
$dir = "{$_SERVER["DOCUMENT_ROOT"]}/dir/{$variable}"
[1] otherwise known as yet another richardian fuckup
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|