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 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?