doudun5009 2014-01-30 06:42
浏览 734
已采纳

解析错误:语法错误,意外'未设置'(T_UNSET)

I am using simple php unset() function to remove and index of array but it's showing error

Parse error: syntax error, unexpected 'unset' (T_UNSET)

Error. here is the syntex

echo $totalArray  =     unset($linkExtHelp[0]); 

Thanks in advance.

  • 写回答

3条回答 默认 最新

  • dtd58256 2014-01-30 06:47
    关注

    Try this, Reason for unset($linkExtHelp[0]) assigning to the variable echo $totalArray = You can't assign the unset() value to the variable, You can use to check before unset and after unset as like below. In other words, unset does not have any return value, since unset is a void. Void - does not provide a result value to its caller.

    Syntax: void unset ( mixed $var [, mixed $... ] )

    echo "Before unset:",$linkExtHelp[0];
    unset($linkExtHelp[0]);
    echo "After unset:",$linkExtHelp[0];
    

    instead of

    echo $totalArray  =     unset($linkExtHelp[0]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?