doujiyuan0211 2016-09-12 01:15
浏览 37

如果要将所有PHP函数与jQuery(Ajax)结合使用并获得响应,最好将所有PHP函数放在单独的文件中吗?

I normally put all functions in separate files, but I'm imagining ways to put everything in one file.

You could probably send the name of the needed PHP function along with each ajax-call and write something like the following in the PHP-file:

if($_POST['function_name'] == 'myfunction'){
myfunction();
}

function myfunction()
{
echo 'This to be echoed.'
}

Somehow that feels wrong. So, what is your opinion? All functions in one file or all separated?

  • 写回答

2条回答 默认 最新

  • drxp993551 2016-09-12 01:59
    关注

    If your project is really big and has lots of people engaged to the project, separating files for each functions would be a nice option to work together.

    But if it's not the case like that, putting every functions in one file will make your project looks more simple and productive.

    Please note that this is just my personal opinion.

    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64