I have a web store in PHP + MySQL. I have used a custom micro-CMS which allows products and its details (price, description, units available, etc.). The function that calculates the prices, directly from database and applying different rules is get_price_of_product( $id_product )
, which let's say exists in includes/functions.php
.
Now if I want to customize the micro-CMS for different customers and don't want to change the core code, I would still use the function but I need some way of calling a custom-made function, different for any different customer: CUSTOM_ID_get_price_of_product
, which lives in includes/functions-CUSTOM_ID.php
. ( Each different domain will use a different installation, with only that file being different in each installation ).
I had thought of checking function_exists
in get_price_of_product
, and accordingly, return the correct value, but I am not sure if there is a penalty on processing time, memory or otherwise.
I understand that other options, as storing the function name in the database and eval()
'ing the function could be potentially dangerous (security breach). Other options ?