<?php
declare (strict_types = 1);
namespace app\controller; use app\BaseController;
use think\facade\Db; class Index extends BaseController
{
public function index()
{
$this->hello((int) $_GET['a']);
$a = Db::name('user')->where('id', 1)->find(); return json($a);
} public function hello(string $name = 'ThinkPHP6')
{
return 'hello,' . $name;
}
}

1.declare (strict_types = 1); //开启严格模式,检查参数的类型

Argument 1 passed to app\controller\Index::hello() must be of the type string, int given, called in /www/wwwroot/test/tp6/app/controller/Index.php on line 12

1.传参和定义的类型不一致会直接报错,去掉严格模式不会报错

2.hello(string $name = 'ThinkPHP6') //hello函数定义name必须传字符串类型

3.$this->hello((int) $_GET['a']); //实际传参时候给了一个整形

4.declare (strict_types = 1); 在严格模式下直接报错

最新文章

  1. android 复制字符串到剪贴板
  2. wordexpress
  3. IIS:日志代码分析
  4. linux+php+apache+mysql(mariadb)故障排除
  5. Hibernate 的saveOrUpdate方法(转)
  6. ASP.NET MVC5 插件化机制简单实现
  7. aspx页面Page_Load和aspx页面上控件Page_Load事件执行顺序
  8. OSGI.NET 学习笔记--应用篇
  9. [LeetNode]Sort List
  10. ASP.Net网站部署失败
  11. Python 基础-python环境变量、模块初识及字符类型
  12. css考核点整理(九)-有几种文字替换方式,之间的优缺点
  13. CentOS安装错误:no default or ui configuration
  14. BZOJ 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富( dp )
  15. 大数据系列修炼-Scala课程02
  16. windows8.1安装之后的感想
  17. 安徽省2016“京胜杯”程序设计大赛_E_转啊转
  18. js的基础要点
  19. ubuntu10.04 安装配置tftp服务
  20. VB.NET 泛型类型的应用经验

热门文章

  1. Smart200 设计注意设计
  2. react+Native使用typeScript
  3. 解决CORS跨域问题
  4. c++练习271题:水仙花数
  5. 分析网络工具 Wireshark与tcpdump
  6. React 安装 Sass 错误问题; node-sass 安装运行成功 yarn add sass node-sass@npm:sass
  7. leecode75. 颜色分类
  8. vscode 报错command line option ‘-std=c11‘ is valid for C/ObjC but not for C++
  9. django源码剖析(steup、runserver、生命周期)
  10. c--&gt; #define 定义宏