尝试将我的Laravel项目上传到实时Web服务器时遇到问题。一切都在本地服务器上完美运行。但是,我的本地服务器运行的是PHP 7.2.6,而我的主机服务器目前仅支持7.1。因此,当我尝试为服务器设置cron作业以运行Laravel计划的任务时,出现此错误:
解析错误:语法错误,意外的“类”(T_CLASS),预期标识符(T_STRING)或变量(T_VARIABLE)或第31行的/ home / me / project / artisan中的“ {”或“ $”
此行包含:
export const SIGNED_IN = 'SIGNED_IN';
export const LOGGED_OUT = 'LOGGED_OUT';
//Action Creators
export const checkSigned = () => async dispatch => {
let token = await AsyncStorage.getItem('fb_token');
if(token){
dispatch({type: SIGNED_IN})
}
dispatch({type: LOGGED_OUT})
}
我知道问题与调用Private Sub Worksheet_Change(ByVal Target As Range)
' To allow multiple selections in a Drop Down List
Dim Oldvalue As String
Dim Newvalue As String
Dim rng As Range, listVals
'run some checks
If rng.Cells.Count > 1 Then Exit Sub '<< this first!
Set rng = Application.Intersect(Target, _
Me.Columns(13).SpecialCells(xlCellTypeAllValidation))
If rng Is Nothing Then Exit Sub
If rng.Value <> "" Then
On Error GoTo Exitsub
Application.EnableEvents = False
Newvalue = rng.Value
Application.Undo
Oldvalue = rng.Value
If Oldvalue = "" Then
rng.Value = Newvalue
Else
listVals = Application.Evaluate(rng.Validation.Formula1).Value
rng.Value = SortItOut(listVals, Oldvalue, Newvalue) '<< call function
End If
End If
Exitsub:
If Err.Number > 0 Then Debug.Print Err.Description
Application.EnableEvents = True
End Sub
'Figure out what gets added (or removed) and keep
' it all in the same order as the validation source range
Private Function SortItOut(listVals, oldVal, newVal)
Const THE_SEP As String = ", "
Dim i As Long, arr, s, sep, t, listed, removeNewVal
s = ""
sep = ""
arr = Split(oldVal, THE_SEP)
'new value already listed?
removeNewVal = Not IsError(Application.Match(newVal, arr, 0))
For i = 1 To UBound(listVals, 1)
t = listVals(i, 1)
listed = Not IsError(Application.Match(t, arr, 0))
If listed Or newVal = t Then
If Not (removeNewVal And newVal = t) Then
s = s & sep & t
sep = THE_SEP
End If
End If
Next i
SortItOut = s
End Function
有关,但是我无法将PHP版本更改为7.2来解决此问题。那么,还有其他解决方法吗?我唯一担心的是,即使我解决了这个错误,还会有更多错误。
答案 0 :(得分:1)
您收到的错误似乎表明您正在使用PHP <= 5.4。
cli使用的默认php版本可能与您的网站使用的默认版本不同。
您可以通过在命令行上运行php -v
来检查它正在使用哪个版本。如果版本错误,则应该可以运行whereis php
以获得可用的不同php版本的路径列表。
找到正确的版本后,便可以更新cronjob以使用正确的php可执行文件的路径,例如
/path/to/php /home/username/path-to-artisan schedule:run > /dev/null 2>&1