Re: Full versus relative URLs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----------------------------------------------------------------------
Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
a Free CD of Ubuntu mailed to your door without any cost. Visit :
www.ubuntu.com
----------------------------------------------------------------------


On Wed, Feb 18, 2009 at 8:02 PM, Stuart <stuttle@xxxxxxxxx> 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
>

. (dot)  is string concatenator/concatenation operator. And  .. (double dot)
used in a path is a shorthand for parent directory.  Goto your command
console . ie.  CMD or Command.com or linux console type  cd .. and press
enter it will take you to one level up.  also in this shorthand . (a single
dot) means current directory/folder (please dont mixup with concatenation
operator)

>
>
> 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
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux