Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13490 > unrolled thread

scandir problem

Started byrichard <noreply@example.com>
First post2014-05-03 11:43 -0400
Last post2014-05-03 22:11 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  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

#13490 — scandir problem

Fromrichard <noreply@example.com>
Date2014-05-03 11:43 -0400
Subjectscandir problem
Message-ID<zyks8bdzibyb$.56tg86o2exse.dlg@40tude.net>
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

[toc] | [next] | [standalone]


#13491

Fromrichard <noreply@example.com>
Date2014-05-03 12:08 -0400
Message-ID<cc2c3ox9cdk1.q2va0waql0q4$.dlg@40tude.net>
In reply to#13490
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.

[toc] | [prev] | [next] | [standalone]


#13499

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-05-03 22:11 +0000
Message-ID<lk3pho$aom$2@dont-email.me>
In reply to#13491
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web