You are here: Re: [PHP] what is this: dirname(__FILE__)? « PHP « IT news, forums, messages
Re: [PHP] what is this: dirname(__FILE__)?

Posted by Robert Cummings on 08/01/05 03:18

On Sun, 2005-07-31 at 20:04, Sam Smith wrote:
> I don't recognize this something(__SOMETHING__) format. I know what it's
> doing but I don't know how it's doing it.

Constants of the type __SOMETHING__ are historical constants for
retrieving contextual information about the source code in which the
constant is found. For instance __FILE__ indicates the name of the
source file in which the __FILE__ constant is found. This nomenclature
dates back to at least C and is probably kept for historical reasons
since everyone knows C is da bomb!

> The whole thing is "$fdf_dir=dirname(__FILE__).'/results';" and of course
> it's setting that var $fdf_dir to the path to a file.

This means it's setting $fdf_dir to the path to a file called "results"
that is in the same directory as the source file containing __FILE__.

> Is there something significant about the double underscores "__"?

Yep as stated above :) There are numberous such constants such as
__LINE__ to retrieve the current source code line number (very useful
for debugging at times), __CLASS__, __FUNCTION__ etc.

> Why the parentheses, it's not a function?

dirname() is a function.

> Sorry lame question but I don't know this.

RTFM ;)

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация