//操作の追加
public function addUser(Request $request)
{
$data = $request -> param();
$status = 1;
$message = '正常に追加されました';
$rule = [
'name|ユーザー名' => "require|min:3|max:10",
'password|パスワード' => ; "require|min:3|max:10",
'email|mailbox' => 'require|email'
];
$result = $this -> validate( $ data, $rule);
//return ['status'=>$status, 'message'=> $result ];
if ($result === true) {
// return ['status'=>$status, 'message'=>$request->param()];
$user= UserModel::create($request->param() }
return ['status'=>$status, 'message'=>$message];
}
You bad bad2018-07-13 16:34:52
あなたの戻り値 ['status'=>$status, 'message'=>$message]; assign() を使用すべきではないでしょうか?データ型エラーを視覚的に検査することもできます。 $data などのデータ変数に [0] を追加します。 。 。 $data[0] の出力を見てください
紫轩 ADG2018-07-11 17:43:15
[0] InvalidArgumentException in Response.php 行 316
変数型エラー:array
{
if (null == $this->content) {
$content = $this- >output($this->data);
if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([
$content, '__toString', ]) ) { 新しいものを投げるInvalidArgumentException(sprintf('変数型エラー: %s', gettype($content))); } $this->content = (文字列) $content; } $this->content; を返す } /** * 获取状態态码ファイル空Cookiesthinkphp_show_page_trace0|0PHPSESSIDb1e4csbk4p7etj8p50l4m9r0r6セッションthink { "ユーザー ID": 1, "ユーザー情報": { "ID": 1, "名前": "管理者"、"パスワード": "e10adc3949ba59abbe56e057f20f883e"、"メール": "admin123@php.cn"、"役割": 1、"ステータス": 1、"作成時刻": 1501493848、"更新時刻": 1531298974、 "delete_time": null, "login_time": 1531298973, "login_count": 23, "is_delete": 1 } }サーバー/リクエストデータPATHC:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C: WindowsSystem32WindowsPowerShellv1.0;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommonSYSTEMROOTC:WindowsCOMSPECC:Windowssystem32cmd.exe
PATHEXT.COM ;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSCWINDIRC:WindowsPHP_FCGI_MAX_REQUESTS1000PHPRCC :/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_PROTOC OL
HTTP/1.1
GATEWAY_INTERFACE
CGI/1.1
REDIRECT_QUERY_STRING
/index/user/adduser.html
REDIRECT_URL
/index/user/adduser.html
REMOTE_PORT
51873
SCRIPT _ファイル名
D:/php/tp5/ public/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_SOFTWARE
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
close
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
環境変数
empty
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
d:phptp5runtimecache
TEMP_PATH
D:phptp5runtimetemp
CONF_PATH
D:phptp5public/../application/
CONF_EXT
.php
ENV_PREFIX
PHP_
IS_CLI
false
IS_WIN
true
USER_ID
1
ThinkPHP V5.0.20 { 十年磨一剑-API开公開设计の高性能フレーム}
0.103005s