0

There is an error saying, headers are already sent, showing that print_r occuring the error, but in tutorial the print_r's array appears before navbar at the top of web page

class PostController extends AppController
{
    public function actionTest()
    {
        $names = ['Ivanov', 'Petrov', 'Sidorov'];

        print_r($names);

        return $this->render('test');
    }

}

1 Answers1

1

YOu shuold not output values with echo, print_r or var_dump .. before return

class PostController extends AppController
{
  public function actionTest()
  {
    $names = ['Ivanov', 'Petrov', 'Sidorov'];


    return $this->render('test');
  }

}

in your case remove print_r($names);

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107