解析错误:语法错误,意外的“?”,在 Laravel 中需要变量(T_VARIABLE)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48883778/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in Laravel
提问by Karthik
In my Laravel Web Application I got following error in following Line. When Laravel Email Trigger
在我的 Laravel Web 应用程序中,我在以下行中遇到以下错误。当 Laravel 电子邮件触发时
Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)
解析错误:语法错误,意外的“?”,期望变量(T_VARIABLE)
$order=array();
$order['contactname']=$customername;
$order['contactnumber']=$cusconnum;
$order['pickupaddress']=$request->input('pickupaddress');
$order['deliveraddress']=$request->input('deliveryaddress');
$order['pickupdate']=$request->input('pickupdate');
$order['refnos']= $bookingpre."".$curbookingid;
$myemail="[email protected]";
Mail::to($myemail)->send(new OrderBooked($order)); /* Error Raised Line */
following code for orderbooked mail
以下代码用于订购邮件
OrderBooked.php
订单预订.php
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class OrderBooked extends Mailable
{
use Queueable, SerializesModels;
protected $order;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct(array $order)
{
$this->order = $order;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('[email protected]')->markdown('emails.orders.booked') ->with(['contactname' => $this->order['contactname'],'contactnumber' => $this->order['contactnumber'],'pickupaddress' => $this->order['pickupaddress'],'deliveraddress' => $this->order['deliveraddress'],'pickupdate' => $this->order['pickupdate'],'refnos' => $this->order['refnos'],]);
}
}
回答by Sagar Gautam
You have unnecessary comma at the end of the following line just remove that.
在下一行的末尾有不必要的逗号,只需将其删除即可。
public function build()
{
return $this->from('[email protected]')->markdown('emails.orders.booked') ->with(['contactname' => $this->order['contactname'],'contactnumber' => $this->order['contactnumber'],'pickupaddress' => $this->order['pickupaddress'],'deliveraddress' => $this->order['deliveraddress'],'pickupdate' => $this->order['pickupdate'],'refnos' => $this->order['refnos']]);
}