douping3427 2010-08-13 12:49
浏览 26
已采纳

如何创建PHP单例类来处理请求变量?

was thinking about creating a Single class called 'Request' to handle and clean POST and GET variables but being new to the singleton pattern I'm not sure how to implement it. Ideally I'd like to have 2 functions post($name,$clean) and get($name,$clean) - $clean being a boolean to determine whether to trim/ escape the value

  • 写回答

2条回答 默认 最新

  • dpglo66848 2010-08-13 12:55
    关注

    I'm not sure why you think this is a good candidate for a singleton - I've have thought a simple static class would make much more sense. (Incidentally, I presume you're using the built in filter functions?)

    Whilst a gross simplification, singleton's are good at limiting/controlling access to a finite resource which isn't really the case in this instance.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Linux权限管理相关操作(求解答)
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表
  • ¥15 DbVisualizer Pro 12.0.7 sql commander光标错位 显示位置与实际不符
  • ¥15 android 打包报错