note 27264 added to function.parse-ini-file
| From: | fbeyer at clickhand dot de | Date: | Fri, 29 Nov 2002 15:37:23 +0000 |
| Subject: | note 27264 added to function.parse-ini-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40119@lists.php.net to get a copy of this message | ||
Besides the features mentioned above (eg. core constants, booleans), you can also access
user-defined constants in ini files! This is handy if you want to create a bit-field, for example:
+++ PHP +++
// Define pizza toppings
define('PIZZA_HAM', 1);
define('PIZZA_PINEAPPLE', 2);
define('PIZZA_ONION', 4);
define('PIZZA_MOZARELLA', 8);
define('PIZZA_GARLIC', 16);
// Read predefined pizzas
$pizzas = parse_ini_file('pizzas.ini');
if ($pizzas[$user_pizza] & PIZZA_ONION) {
// Add onions to the pizza
}
+++ INI +++
[pizzas]
; Define pizzas
hawaii = PIZZA_HAM | PIZZA_PINEAPPLE
stinky = PIZZA_ONION | PIZZA_GARLIC
--
http://www.php.net/manual/en/function.parse-ini-file.php
http://master.php.net/manage/user-notes.php?action=edit+27264
http://master.php.net/manage/user-notes.php?action=delete+27264
http://master.php.net/manage/user-notes.php?action=reject+27264