Jump to content

Head function loads in body


matthijs110

Recommended Posts

Hello,

 

 

I've made a function that contains the html header (<head>). When I call that function in a other file, with the header file included, it puts the header function in the body. So all the meta tags are in the body, instead of the head. 

 

Would it be possible to load this all in the head? 

 

The head function does contain the html and head tags. However, without them, it still doesn't want to go to the head.

 

Link to comment
Share on other sites

Can you show us this call?  That would be so much easier to debug than taking a flying leap at whatever you are talking about.

Sure,

 

LayoutController.php:

 

function head(){
        
    ?>
        <html lang="en">
            <head>
                <meta charset="utf-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
                <meta name="author" content="matthijs110">
      
                <link href='//fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,300italic,400italic,500italic,700italic' rel='stylesheet' type='text/css'>
                <link href='//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
      

                <!-- Bootstrap core CSS -->
                <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
      
                <!-- FontAwesome Icons -->
                <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
      
                <!-- Bootstrap Core JS -->
                <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
                <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
                <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

                <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
                <!--[if lt IE 9]>
                    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
                    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
                <![endif]-->
      
                <meta name="apple-mobile-web-app-title" content="Panel">
                <meta name="apple-mobile-web-app-capable" content="yes">
      
            </head>

        </html>

    <?php
    }
    ?>

And in my profile.php:

 

 

<head>
    <?php
        require_once('Code/Controllers/LayoutController.php');
        head();
    ?>
</head>
Link to comment
Share on other sites

Let's see.  You have a head tag, then you include some code, then you call a function from that include which re-issues a head tag, close the head, and then you issue a second end head tag.  AND you open and close your html inside of the header section.  I would think that any browser would have a huge problem handling this mess.

 

BTW - why a function?  You're including static html code - why make it a php function?

Link to comment
Share on other sites

head() should be more like

<html>
 <head>
  ...head code
 </head>
 <body> (no closing html!!!)

Then create a foot(), which would be something like

  </body>
</html>

Then profile would sandwich the actual content between the head() and foot(), like:

<?php
require_once('Code/Controllers/LayoutController.php');
head(); //create the header
?>
 <div>This is the profile page</div> //insert the page code in the body
<?php foot(); //create the footer which closes the body/html to complete the page ?>
Edited by CroNiX
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.