AW: AW: [PHP] beginners question
| From: | Tobias Fichtner | Date: | Wed, 15 Oct 2014 14:04:31 +0000 |
| Subject: | AW: AW: [PHP] beginners question | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323965@lists.php.net to get a copy of this message | ||
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@albanyhandball.com]
Gesendet: Mittwoch, 15. Oktober 2014 15:26
An: php-general@lists.php.net
Betreff: Re: AW: [PHP] 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: [application/pkcs7-signature] smime.p7s
Attachment: [application/pkcs7-signature] smime.p7s