如果不存在import sys
PY3K = sys.version_info >= (3, 0)
if PY3K:
source = sys.stdin.buffer
else:
# Python 2 on Windows opens sys.stdin in text mode, and
# binary data that read from it becomes corrupted on \r\n
if sys.platform == "win32":
# set sys.stdin to binary mode
import os, msvcrt
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
source = sys.stdin
b = source.read()
,则$category
未定义。那么如果只有它存在,我怎么能通过$category
。
$category
答案 0 :(得分:1)
您只需将Method中的hi hello world!
abc def ghijkl mno pqr!
初始化为空值即可。因此,即使您的$category
未能conditional logic
,我们也会有一个空值来回落.....
override $category
<强>可替换地:强>
<?php
public function receive(Request $request) {
$category = null; //<== INITIALIZE THE $category VARIABLE TO NULL.
if ($request->ajax()) {
if ($id = $request->id) {
$receive = User::where(['id' => $id])->first();
if (isset($receive->category->name)) {
$category = $receive->category->name;
}
die( json_encode([
'status' => TRUE,
'receive' => $receive,
'category' => $category
]));
}
}
}
答案 1 :(得分:1)
试试这个......
$category = isset($_GET['category']) ? $_GET['category'] : '';