On Wed, Feb 18, 2009 at 12:05 PM, PJ <af.gourmet@xxxxxxxxxxxx> wrote: > Stuart wrote: > > 2009/2/18 PJ <af.gourmet@xxxxxxxxxxxx>: > > > >> Stuart wrote: > >> > >>>>> <?php include dirname(__FILE__)."/../header.php"; ?> > >>>>> > >> This generates a Fatal error: Cal to undefined function dirname() .... > ???? > >> > > > > The dirname function is present in both PHP 4 and 5 and does not rely > > on any external libraries. Are you sure you're spelling it right? > > > > http://php.net/dirname > > > > > >> I must be really dense... > >> What I don't understand in the above is this - dirname refers to what > >> directory? -- the directory of the file that is including? what if the > >> directory is the root directory of the site? > >> > >> (_FILE_) = what? - (_filename.ext_) or (filename.ext) --- what file is > >> this, the file which is including the file header.php? > >> > > > > The __FILE__ (note 2 _'s either side) constant is the full path and > > filename to the current script. The dirname function knocks the > > filename off it to give you the directory the current script is in. > > You can then append a / and then the relative path to the script you > > want to include. By doing this you're ensuring that all includes are > > relative to the current script and are not affected by ini settings or > > anything else. > > > > > >> and what does the . mean and then "/../header.php" --- I don't > >> understand what to enter here > >> > > > > The . is the string append operator. I tend to assume the most basic > > level of PHP knowledge from users of this list and I include the > > string append operator in that set. You might want to find a beginners > > tutorial for PHP and work through that to give you a solid foundation > > before attempting to work with multiple scripts. > > > > -Stuart > > > > > What confused me here is that often, in examples, there are all sorts of > references to files and there seems to be no standard as to how to refer > to them in non-scripts such as these e-mails. So, I thought that > dirname(_FILE_) was a general reference to a directory name and a > file... :-( > I don't want to defend myself here, but I cannot be expected to know all > functions and look up anything that might resemble a function... > I still do not understand, and that is the keyword here, I am trying to > understand things - what does /../header.php mean. I know the 2 dots > mean a higher directory in Unix... but I understood that ../ would mean > the root directory - so what is the / before the ../header.php mean? > When including scripts or pages, i find that if I am referencing to the > current directory, just the filename or /filename works. If the > reference is up a level, ../ works > > e.g. to reference root/images/ from root/authors = ../images/file.ext > from root = /images/file.ext or images/file.ext > > I haven't needed to go to a deeper level yet. > > -- > > Phil Jourdan --- pj@xxxxxxxxxxxxx > http://www.ptahhotep.com > http://www.chiccantine.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > ../../ means go up two directories from the current working directory that your file is in -- Bastien Cat, the other other white meat