【问题标题】:laravel 4 error on line that dosn't exist in routes.php在routes.php中不存在的laravel 4错误
【发布时间】:2014-01-05 12:24:14
【问题描述】:

我有一个问题正在杀死我,请帮助我。

当我在 routes.php 中忘记分号时,我在 laravel 4 中进行了一个项目,屏幕错误 laravel 警告我,但添加分号后错误仍然存​​在,所以我删除了“整个代码块”错误,但 laravel 仍然在该行上给了我一个不再存在的错误。所以我删除了routes.php文件,但是laravel仍然给了我同样的错误,现在我放回了routes.php但是视图给了我奇怪的结果,我仍然得到关于缺少分号的错误。

我为我的错误英语道歉。 非常感谢。

编辑:好的,我很抱歉.. 但我不知道要写什么代码,因为这个错误太奇怪了

错误是: Symfony\Component\Debug\Exception\FatalErrorException …/app/routes.php116

语法错误,意外的 T_FOREACH

Route::post('/realtime_callback',  function() 
{

    $post = Input::all();
    $a = print_r($myString, true);
    file_put_contents('activity.log', "\r\n".$myString[0]["subscription_id"], FILE_APPEND)
    /*line 116*/foreach($myString[0]['data'] as $item)
        file_put_contents('text.log', "\r\naa".$item, FILE_APPEND);

但实际代码是:

Route::post('/realtime_callback',  function() {

$post = Input::all();

/*line 116*/$evento = Evento::where('subscription_id', '=', $post[0]["subscription_id"]);

$search = new SearchTag($evento->tag);

$response = json_decode($search->sendRequest($evento->min_id));

foreach($response->data as $item) {

    $photo_exist = Photo::where('id', '=', $item->id);

    if(is_null($photo_exist))
        $photo = new Photo();
        $photo->id = $item->id;
        $photo->eve_cod = $evento->name;
        $photo->save();
}

Evento::where('name', '=', $event_name)->update(array('min_id' => $response->pagination->min_tag_id));
});

奇怪的结果意味着视图显示的结果与以前的不同,几乎所有页面都将我带回到 404 页,否则对应的 /

Route::get('/', function(){

//return Redirect::to('users/register');
return "hello";
});

【问题讨论】:

  • 我们需要更多细节......请写下你得到的错误 + 给我们看一些代码......并检查你没有使用像 apc 或 opCache 这样的缓存
  • 请发布错误和你的 routes.php
  • 我已经添加更多信息,非常感谢

标签: php laravel laravel-routing


【解决方案1】:

在这个代码块中

Route::post('/realtime_callback',  function() 
{
    $post = Input::all();
    $a = print_r($myString, true);
    // This line is missing the semicolon at the end
    file_put_contents('activity.log', "\r\n".$myString[0]["subscription_id"], FILE_APPEND)
    /*line 116*/foreach($myString[0]['data'] as $item)
    file_put_contents('text.log', "\r\naa".$item, FILE_APPEND);

您在file_put_contents 所在的行中错过了一个分号,就在foreach 行之前。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-24
    • 2015-01-03
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多