Php compact():未定义的变量
嗨,我有一个laravel应用程序在本地正常工作,但在服务器上不工作,下面是它抛出的部分和错误:Php compact():未定义的变量,php,laravel,Php,Laravel,嗨,我有一个laravel应用程序在本地正常工作,但在服务器上不工作,下面是它抛出的部分和错误: compact(): Undefined variable: 00558852 // the number is what user have inserted 代码如下: public function sendSms(Request $request) { $cellphone = $request->mobile; // se
compact(): Undefined variable: 00558852 // the number is what user have inserted
代码如下:
public function sendSms(Request $request)
{
$cellphone = $request->mobile;
// sending sms
$token = rand('11111', '99999');
$client = new Client(); //GuzzleHttp\Client
$key = '4C77664C384B376F6A59376A3737496F31533954556D717353574A416249314A376B4E4C4B7A4A466C70343D';
$result = $client->post('https://api.kavenegar.com/v1/' . $key . '/verify/lookup.json
', [
'form_params' => [
'receptor' => $request->mobile,
'token' => $token,
'template' => 'Register',
]
]);
$temp = Temp::where('cellphone', $request->mobile);
if ($temp) {
$temp->delete();
}
$created = Temp::create([
'cellphone' => $request->mobile,
'code' => $token,
]);
return view('shop::customers.signup.verify-sms', compact('cellphone', $cellphone));
首先,我认为这是因为php版本我降级到了7.2,但它仍然抛出了同样的错误。使用compact('mobile')
。例如:
return view('shop::customers.signup.verify-sms', compact('cellphone'));
只需使用compact('mobile')
。例如:
return view('shop::customers.signup.verify-sms', compact('cellphone'));