473,412 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

problem with functions and paths


Can anyone tell me how PHP handles paths?
Do all functions require fully qualified paths or can some use relative
paths?

I'm having a problem with a foreach/glob() at the moment but have others
to sort out. Is it different for windows and linux?

On Windows:
if I do (using apache2)

$path = 'c:\server\mydomain\';

foreach (glob($path . "*", GLOB_ONLYDIR) as $folder) {
dothis();
}

It all works fine but if I set $path as:
$path = '../../../mydomain/';

I get an:
Warning: Invalid argument supplied for foreach()
I've tried reversing and escaping the slashes with no luck.

Is there a fixed rule for relative & fully qualified paths?

Thanks
Jun 19 '07 #1
1 1372
harvey wrote:
>
Can anyone tell me how PHP handles paths?
Do all functions require fully qualified paths or can some use relative
paths?

I'm having a problem with a foreach/glob() at the moment but have others
to sort out. Is it different for windows and linux?

On Windows:
if I do (using apache2)

$path = 'c:\server\mydomain\';

foreach (glob($path . "*", GLOB_ONLYDIR) as $folder) {
dothis();
}

It all works fine but if I set $path as:
$path = '../../../mydomain/';

I get an:
Warning: Invalid argument supplied for foreach()
I've tried reversing and escaping the slashes with no luck.

Is there a fixed rule for relative & fully qualified paths?

Thanks
Hi,

I never used relative paths in glob.
Why not make a full path first of your relative path?

And also: Why not check first if your target directory is actually a
directory before feeding it to glob? Use function is_dir().

Regards,
Erwin Moller

Jun 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Crowe | last post by:
Hi guys, I've come across a rather strange, and very anoying problem. On /some/ PHP sites that we're developing on 2 different servers, files that are in the root of the website are unable to...
7
by: Lars Plessmann | last post by:
I hava several php files in different folders. I tried to use relative paths. But when I call a script from another folder that has another depth, it cannot find the files that are embedded via...
3
by: Trevor Fairchild | last post by:
I am making a program that categorizes pictures. The picture paths are stored in an Access Database, vb6 connects using adodc controls. This program works specifically with .jpg files. It will be...
6
by: Rami A. Kishek | last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I hope someone here can shed some light. First of all, I have this piece of code which uses shelve to save instances of some...
6
by: Chiller | last post by:
I'm in the process of writing a class that performs functions on a Distance object. The object is created by entering details as "Distance a (5, km)" or "Distance b (3, cm)" etc. I wish to write...
1
by: Dave | last post by:
I've been having trouble with the development of my ASP.NET site. The problem stems from the fact that I use one development server for many projects like www.devserver.com/project/, but each...
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
6
by: ajikoe | last post by:
Hello I tried to combine c++ and python together. So I follow from this website: http://kortis.to/radix/python_ext/ I have this code: # prmodule.c static PyObject *pr_isprime(PyObject *self,...
6
by: Mohammad Omer | last post by:
Hi, I tried to validate file path without calling file creating functions. Is it possible? How? Regards, -aims
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.