473,513 Members | 4,116 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

include()

I don't completely understand the documentation for the include() function:

"Files for including are first looked in include_path relative to the
current working directory and then in include_path relative to the directory
of current script. E.g. if your include_path is ., current working directory
is /www/, you included include/a.php and there is include "b.php" in that
file, b.php is first looked in /www/ and then in /www/include/. "

How do you know where "the current working directory" is?
Jul 17 '05 #1
2 1936
Mike wrote:
How do you know where "the current working directory" is?


If you mean, how do you find out programmatically what it is, use the
getcwd() function.

If you mean, how do you as a programmer know what it should be ahead of
time, it's usually the directory containing the top-level script that's
being executed. (This may not hold true for command-line execution, but
should for web execution.)

So if the web server is loading up A.php, and A.php include()s B.php, in
B.php the working directory is still the location of A.php. (Unless of
course you've used chdir() to change it.)

-- brion vibber (brion @ pobox.com)
Jul 17 '05 #2

"Mike" <mi*******@nospam.msn.com> wrote in message
news:ad******************@bignews4.bellsouth.net.. .
I don't completely understand the documentation for the include() function:

"Files for including are first looked in include_path relative to the
current working directory and then in include_path relative to the
directory
of current script. E.g. if your include_path is ., current working
directory
is /www/, you included include/a.php and there is include "b.php" in that
file, b.php is first looked in /www/ and then in /www/include/. "

How do you know where "the current working directory" is?


It is identified in $_SERVER['SCRIPT_FILENAME']. It is the directory from
which the current top-level script is being run. This directory does not
change when you include() from another directory.

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #3

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

Similar topics

43
5043
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is relative NOT to the immediate script that is including it, but is relative to the top-level calling script. In practice, this means that you have to...
0
6078
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL"...
60
8210
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
9
6397
by: zolli | last post by:
Hi, I've been banging my head against this for a while now. Hoping someone here can shed some light on what's going on. On including stdlib.h in a file, I'm seeing the following errors: ----BEGIN ERRORS---- gcc -g3 -DUSE_LIBC -Wall -c -I../mm -I../include -I/usr/include -I/usr/include/linux -o mm_tree_test.o mm_tree_test.c
5
2495
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when...
1
7459
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me a bunch of "missing ;" errors. I did reinstall the whole thing a few times but it didn't work. Anyone have any idea? Thanks c:\Program...
1
4547
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include <iostream.h> in some way examples to the error messages c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872: 'ios' :...
3
2690
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include directories contain a file named "cppfile1.h". In my main project I #include "cppfile1.h". I rely on the order of paths in additional include...
14
6673
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping" process I am introducing namespaces to properly compartmentalise sections of the code into logical units. What I am speciffically trying to get right is...
7
2895
by: Giancarlo Bassi | last post by:
Please, what are here the 11 include files (found over the internet)? */mozzarella.c /* #include #include #include #include #include #include
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7563
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7125
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5102
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.