//添加操作
public function addUser(Request $request)
{
$data = $request -> param();
$status = 1;
$message = '添加成功';
$rule = [
'姓名|用户名' => "require|min:3|max:10",
'密码|密码' => "require|min:3|max:10",
'email|邮箱' => 'require|email'
];
$结果 = $this -> validate($data, $rule);
//return ['status'=>$status, 'message'=>; $result ];
if ($result === true) {
// return ['status'=>$status, 'message'=>$request->param() ];
$user= UserModel::create($request->param());
if ($user === null) {
$status = 0;
$message = '添加失败~~';
}
}
return ['status'=>$status, 'message'=>$message] ;
}
你的 return ['status'=>$status, 'message'=>$message]; 。不是应该用assign()吗。还有目测是数据类型错误。把你的数据变量比如$data加个[0]。。。$data[0]输出看看
[0] InvalidArgumentException 在 Response.php 第 316 行
变量类型错误: array
{
if (null == $this->content) {
$内容 = $这个- >输出($这个->数据);
if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([
$content, '__toString',
]) ) {
抛出新的InvalidArgumentException(sprintf('变量类型错误: %s', gettype($content)));
} $this->content = (string) $content; }
return $this->content; } /** * 获取状态码
Call Stack
在Response.php第316行
在Response->getContent()在Response.php第94行
在Response->send()在start.php第19行
在index.php第17行的require('D:phptp5thinkphp...')
环境变量
GET数据
/index/user/adduser_html
POST数据
空
文件
空
Cookies
thinkphp_show_page_trace
0|0
PHPSESSID
b1e4csbk4p7etj8p50l4m9r0r6
会话
think
{ "user_id": 1, "user_info": { "id": 1, "姓名": "管理员", "密码": "e10adc3949ba59abbe56e057f20f883e", "电子邮件": "admin123@php.cn", "角色": 1, "状态": 1, "创建时间": 1501493848, "更新时间": 1531298974, "delete_time": null, "login_time": 1531298973, "login_count": 23, "is_delete": 1 } }
服务器/请求数据
PATH
C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C: WindowsSystem32WindowsPowerShellv1.0;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon
SYSTEMROOT
C:Windows
COMSPEC
C:Windowssystem32cmd.exe
PATHEXT
。通讯;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR
C:Windows
PHP_FCGI_MAX_REQUESTS
1000
PHPRC
C :/myphp_www/PHPTutorial/php/php-5.6.27-nts/
_FCGI_SHUTDOWN_EVENT_
1796
SCRIPT_NAME
/index.php
REQUEST_URI
/index/user/adduser.html
QUERY_STRING
/index/user/adduser.html
REQUEST_METHOD
GET
SERVER_PROTOCOL
HTTP/1.1
GATEWAY_INTERFACE
CGI/1.1
REDIRECT_QUERY_STRING
/index/user/adduser.html
REDIRECT_URL
/index/user/adduser.html
REMOTE_PORT
51873
SCRIP T_FILENAME
D:/php/tp5/公共/index.php
SERVER_ADMIN
admin@php.cn
CONTEXT_DOCUMENT_ROOT
D:/php/tp5/public
CONTEXT_PREFIX
REQUEST_SCHEME
http
DOCUMENT_ROOT
D:/php/tp5/public
REMOTE_ADDR
127.0.0.1
SERVER_PORT
80
SERVER_ADDR
127.0.0.1
SERVER_NAME
www.tp5.cn
SERVER_软件
Apache/2.4.23 (Win32) OpenSSL/1.0.2j mod_fcgid/2.3.9
SERVER_SIGNATURE
SystemRoot
C:Windows
HTTP_COOKIE
thinkphp_show_page_trace=0|0; PHPSESSID=b1e4csbk4p7etj8p50l4m9r0r6; thinkphp_show_page_trace=0|0
HTTP_ACCEPT_LANGUAGE
zh-CN,zh;q=0.9
HTTP_ACCEPT_ENCODING
gzip, deflate
HTTP_ACCEPT
text/html,application/xhtml+xml,application/xml;q=0.9, image/webp,image/apng,*/*;q=0.8
HTTP_USER_AGENT
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, 如 Gecko) Chrome/67.0.3396.99 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS
1
HTTP_CONNECTION
关闭
HTTP_HOST
www.tp5.cn
REDIRECT_STATUS
200
FCGI_ROLE
RESPONDER
PHP_SELF
/ index.php
REQUEST_TIME_FLOAT
1531301786.1009
REQUEST_TIME
1531301786
PATH_INFO
/index/user/adduser.html
环境变量
空
ThinkPHP常量
APP_PATH
D:phptp5public/../application/
THINK_VERSION
5 .0.20
THINK_START_TIME
1531301786.1089
THINK_START_MEM
144840
EXT
.php
DS
THINK_PATH
D:phptp5thinkphp
LIB_PATH
D:phptp5thinkphplibrary
CORE_PATH
D:phptp5thinkphplibrarythink
TRAIT_PATH
D :phptp5thinkphplibrarytraits
ROOT_PATH
D:phptp5
EXTEND_PATH
D:phptp5extend
VENDOR_PATH
D:phptp5vendor
RUNTIME_PATH
D:phptp5runtime
LOG_PATH
D:phptp5runtimelog
CACHE_PATH
D:phptp5runtimecache
TEMP_PATH
D:phptp5runtimetemp
CONF_PATH
D:phptp5public/../application/
CONF_EXT
.php
ENV_PREFIX
PHP_
IS_ CLI
假
IS_WIN
真
USER_ID
1
ThinkPHP V5.0.20 {十年磨一剑-为API开发设计的性能框架}
0.103005s
没有报错吗?你这个是ajax 返回,没反应的话 F12看看错误信息