dragon0023 2013-04-29 14:44
浏览 9

如何使用前端和后端构造类(PHP)

I have a question about how to structure classes. Lately I've been working on changing my PHP coding style over to newer standards since although I'm employed and do a lot of PHP coding for web apps, I'm starting to notice the way I code is rather old and frowned upon. Here's a question. If I have a small blog section on my website and have one class for blog (clsBlog.php) that does all the lifting to build my blog on the frontend, do I also store methods to upload the blog from the backend inside that class? I've usually just created a class called clsAdmin.php and had all the methods that the admin utility uses.

  • 写回答

1条回答 默认 最新

  • dongwen1871 2013-05-04 21:23
    关注

    You could have given us some examples of your current style. That would have let people to at least gage your current skill level.

    I assume that the "frowned upon" style of programming, that you mentioned, can be described as "include based programming". Since I have never really used it, I cannot give you a clean & tested recipe for advancing.

    The best I can offer you would be the list of links at the end of this answer. I would recommend to begin with "PHP Object-Oriented Solutions" book. Though, if you also have problems with newer PHP syntax, you might benefit from quickly skipping through "Beginning PHP 5.3".

    Also, another thing you might look into might be the newer SQL API. There has begun a deprecation process for the ancient mysql_* functions. You should look into some alternatives. If you decide to go with PDO, then I would urge you to check this tutorial.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集