note 73339 modified in language.constants by danbrown
| From: | danbrown@php.net | Date: | Fri, 05 Mar 2010 15:56:17 +0000 |
| Subject: | note 73339 modified in language.constants by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166704@lists.php.net to get a copy of this message | ||
Note that constants can also be used as default argument values
so the following code:
<?php
define('TEST_CONSTANT','Works!');
function testThis($var=TEST_CONSTANT) {
echo "Passing constants as default values $var";
}
testThis();
?>
will produce :
Passing constants as default values Works!
(I tried this in both PHP 4 and 5)
--was--
Note that constants can also be used as default argument values
so the following code:
define('TEST_CONSTANT','Works!');
function testThis($var=TEST_CONSTANT) {
echo "Passing constants as default values $var";
}
testThis();
will produce :
Passing constants as default values Works!
(I tried this in both PHP 4 and 5)
http://php.net/manual/en/language.constants.php