Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #13499
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: scandir problem |
| Date | 2014-05-03 22:11 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lk3pho$aom$2@dont-email.me> (permalink) |
| References | <zyks8bdzibyb$.56tg86o2exse.dlg@40tude.net> <cc2c3ox9cdk1.q2va0waql0q4$.dlg@40tude.net> |
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@gmail.com
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
scandir problem richard <noreply@example.com> - 2014-05-03 11:43 -0400
Re: scandir problem richard <noreply@example.com> - 2014-05-03 12:08 -0400
Re: scandir problem Denis McMahon <denismfmcmahon@gmail.com> - 2014-05-03 22:11 +0000
csiph-web