dongtuo4132 2016-02-09 03:00
浏览 37
已采纳

为什么下划线(_)用于php codeigniter中的函数_save_cart等函数?

I saw many tutorials underscores (_) are used in function.

But I don't know why it is used and how can I use ?

Like this :

function _save_cart()
{

}
  • 写回答

4条回答 默认 最新

  • dongyu2764 2016-02-09 05:17
    关注

    In objective languages functions and variables names seperate with capitalize char, forexample: saveCart(), getCart(), ...

    But in functional languages people use underscore and i think it comes from C posix standarts/notations.

    C language doesn't support private and protected keywords so people generally use one or two underscore as pre extension for make the function private or protected.

    Php firstly created as a functional language after a long time ZEND added object oriented features. So many people used to write it like a functional language. And so if you see a function like _save_cart you can understand that: an old school php coder make this function protected or private with posix way.

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?