我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP类方法参数声明

class myClass {
   function myFunct(Foo $var) {
      ...
   }

   function otherFunct(myClass $other) {
        ...
   }
}

I've seen this declaration couple times in php manual however i dont get it, in this particular example what purpose it serving to have Foo and/or myClass in arguments list for a function?

Is there any use for this declaration outside of class?

Never mind i found it called type declaration (type hints) http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration

近期文章

  • PHP将嵌套的json保存到mysql数据库
  • 独立的WooCommerce逻辑 - 包括?
  • 从PHP调用函数(Javascript)
  • php中的preg_match在html之间获取数据
  • 动态设置更新语句不起作用
  • 我尝试在SQL中创建INSERT WHERE,但它给了我一个错误[重复]
  • Laravel验证列中的唯一值为另一个
  • PHP | 搜索攻击的用户和漏洞[重复]
  • 一个TextField,用于DataTransformer的两个属性
  • 无法通过此查询获得正确的开始日期和结束日期
  • 在非对象上调用成员函数(包括database.php)
  • 警告:mysql_num_fields()期望参数1是资源,在第3026行的... wp-db.php中给出布尔值
  • 通过字符串classname调用类
  • 如何显示php数组?
  • 使用spin.js的jQuery submit()阻止表单提交?
  • MySQL不正确的默认值
  • PHP:如何将格式json_encode模拟为包含html的文本
  • 使用REST GET进行JSON响应 - PHP
  • 无法将json数组解码为php数组
  • PHP 7.1 void返回类型的理解

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华