0

I'm trying to build my app with a MVC pattern, to do that I followed a book. In my index.php page I have a button, when I click on that button I want to call my formController to display a form, I'm trying to do that first just showing a simple text with <h1> but it doesnt show any text just a blank page.

Index.php

<?php
    //check for errors
    error_reporting(E_ALL);
    ini_set("display errors",1);

    include_once "Models/PageData.php";
    $pageData = new PageData();
    $pageData->title = "OSeuCondómiono - Gere tudo apartir de uma única plataforma";
    $pageData->bootstrap = "<link href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'rel='stylesheet'>";
    $pageData->jquery = "<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'></script>";
    $pageData->bootstrapScript = "<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>"; 
    $pageData->googleApiFont = "<link href='https://fonts.googleapis.com/css?family=Merriweather|Open+Sans|Oswald|Roboto'>";
    $pageData->addCss("Css/style.css");
    $pageData->content = include_once "Views/home.php";

    $formButton = isset($_GET['form-nav']);
    if($formButton){
        $pageData->content = include_once "Controllers/loginFormCont.php";
    }
    $page = include_once "Views/layout.php";
    echo $page;
?>

loginFormControler

<?php
    return "<h1>HIIIII</h1>";
?>

that <h1> doesn't display. I don't know why.

pacholik
  • 8,607
  • 9
  • 43
  • 55
  • look this page, it will help you to debug such problems : http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php – mmm Oct 15 '16 at 10:07

1 Answers1

0

Did you try echo instead of return. Return is better to be used inside a function. Yours is used outside a function.

mush
  • 165
  • 1
  • 8
  • echo works, but my controller should interact with a form and then display the result in the index, i just have 1 echo on the index and using this approach i dont need anymore, –  Oct 15 '16 at 10:15