简体   繁体   English

调用脚本时页面无法正确显示

[英]page not displaying correctly when calling script

I'm trying to build my app with a MVC pattern, to do that I followed a book. 我正在尝试使用MVC模式构建我的应用程序,为此我遵循了一本书。 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页面中,我有一个按钮,当我单击该按钮时,我想调用formController来显示一个表单,我试图首先使用<h1>显示一个简单的文本,但它不会显示任何内容文本只是一个空白页。

Index.php 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 loginFormControler

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

that <h1> doesn't display. <h1>不会显示。 I don't know why. 我不知道为什么

Did you try echo instead of return. 您是否尝试过回声而不是返回。 Return is better to be used inside a function. 返回值最好在函数内部使用。 Yours is used outside a function. 您的函数外使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM