Re: Full versus relative URLs
| From: | 9el | Date: | Wed, 18 Feb 2009 14:09:13 +0000 |
| Subject: | Re: Full versus relative URLs | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288533@lists.php.net to get a copy of this message | ||
-----------------------------------------------------------------------
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@gmail.com> wrote:
> 2009/2/18 PJ <af.gourmet@videotron.ca>:
> > 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
>
>