Search code examples
phphtmlcssrequirehead

Php include head with a link to the css dont work


I have started to use php a little bit. And got the first problem, which I can't get rid of. I want my index.php with this code(in the head section):

<head>
<?php
    require 'php/main/head.html';
?>
</head>

get access to my head.html with this code:

<link href="../../style/style.css" rel="stylesheet" type="text/css" />
<link href="../../style/fonts.css" rel="stylesheet" type="text/css">
<link href="../../style/responsive.css" rel="stylesheet" type="text/css">
<link href="http://www.mike-kaufmann.de/global/current_year.css" rel="stylesheet" type="text.css">
<link href="../../img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
// and more code..

The first link should "normally" get the information from the style.css, but it don't take anything. Like it is a wrong path.

The code in the css should do some margin to an element in the index.php; but i said before, it don't do anything.

My question is now: How/ What i have todo to get access to my style.css;

If the code is hard to read you can download it and test it yourself: Dropbox-link or view it on my Github Repo and upload some changes there.

Question: I´ve read that the include function lets the user load the website every time again. Means it don't uses the cache. Is that true? If it is, what can i use instead for good web performance?

Thanks for all answers.

Greetings Mike. :)


Solution

  • My question is now: How/ What i have todo to get access to my style.css;

    You did everything right:

    <meta name="description" content="#"/>
    <meta name="keywords" content="#"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="copyright" content="Last Death" />
    <meta name="author" content="Mike Kaufmann"/>
    <meta charset="UTF-8"/>
    
    <link href="style/style.css" rel="stylesheet" type="text/css" />
    <link href="style/fonts.css" rel="stylesheet" type="text/css">
    <link href="style/responsive.css" rel="stylesheet" type="text/css">
    <link href="http://www.mike-kaufmann.de/global/current_year.css" rel="stylesheet" type="text.css">
    <link href="img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    
    <meta property="og:image" content="http://www.site-check.cc/files/themen/zoom/vorschaubild.jpg"/> <!--Für Facebook links-->
    

    except this code type="text.css" should be type="text/css"

    I´ve read that the include function lets the user load the website every time again. Means it don't uses the cache. Is that true? If it is, what can i use instead for good web performance?

    Yes it is try. But don't be stressed about performance on 3-5 includes. Modern php frameworks usually have much more includes.

    But if you still want to reduce includes load impact then place footer,head and header to one layout.php and lets layout.php then include dynamic php part.