note 27264 modified in function.parse-ini-file by danbrown

From: Date: Sun, 23 Jan 2011 17:18:38 +0000
Subject: note 27264 modified in function.parse-ini-file by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-176183@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 } ?> [pizzas] ; Define pizzas hawaii = PIZZA_HAM | PIZZA_PINEAPPLE stinky = PIZZA_ONION | PIZZA_GARLIC --was-- 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://php.net/manual/en/function.parse-ini-file.php

« previous php.notes (#176183) next »