AW: AW: beginners question

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

 



Hi,

the point is that both include the same files if the include path contains "./" already.

means

include 'config.php'; // include a file named config.php in (default: ".;/path/to/php/pear") follow paths "./" and "/path/to/php/pear/" in this order.
include './config.php'; // include a file named config.php in the same directory. If they would include a config.php from "/path/to/php/pear/" we would have a big problem.

And a god way to include files is to build an absolute path to include like:
[BEGINN define_important_thinks.php || in doc root ]
<?php
define('APP_ROOT' , dirname(__FILE__) . DIRECTORY_SEPARATOR );    // create an absolute path to doc root
[END]

[ BEGINN some_great_application.php || anywhere in your project ]
<?php
require_once './define_important_thinks.php';  //relative path to define_important_thinks.php

include APP_ROOT . 'any_needed_file.php';  // includes any_needed_file.php 

echo 'some source';
[END]


Note: the difference between require and include is the error exception. Require means required and not able to run without (E_COMPILE_ERROR) and include give u an error notice (E_WARNING) that it could not included but PHP try to run the code.

Mit freundlichen Grüßen,
King regards,
Tobias Fichtner

--
[w] http://tobiasfichtner.com/ [gpg] 0x8498F4B2 [fp] 2978 57FB 155B 30BE 7316  AA7D D79C 4A0A 8498 F4B2

-----Ursprüngliche Nachricht-----
Von: Jim Giner [mailto:jim.giner@xxxxxxxxxxxxxxxxxx] 
Gesendet: Mittwoch, 15. Oktober 2014 15:26
An: php-general@xxxxxxxxxxxxx
Betreff: Re: AW:  beginners question

I think that we have a difference in definitions of what a filename is. 
  My def is that 'includes' is not part of a filename.  The filename is simply 'config.inc.php'.  Anything appended to it is part of its location (or path) and not part of the name.  This is based upon the fact that when you actually get to the right location and find the file to be included it is called 'config.inc.php' and nothing else.



--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

<<attachment: smime.p7s>>


[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