drqn5418 2016-06-17 11:40
浏览 296

在PHP中调用另一个自定义函数的最佳方法

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 ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了