1

i have the following codes

in head

<!DOCTYPE html>
<html>
<head>
<title> <?php print $title ?></title>
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>

in index

<?php $ha ="active"; $title ="League of Draven" ?>
<?php require_once  'inc/head.php';?>
<?php require_once 'inc/menu.php';?>
<?php require_once 'inc/footer.php';?>

my css file name is style.css in css folder. The problem is when i put localhost/Myshop in the browser its not picking css file.

Ayaz
  • 53
  • 1
  • 1
  • 7
  • Use `./` or `../` or without `/` whatever you should try to find the correct path. And `print $title` needs closing tag I think `;` – Chay22 Apr 09 '16 at 05:58
  • awesome it works after removing just / before css. Thanks :) – Ayaz Apr 09 '16 at 06:02

2 Answers2

1
/css/style.css

It means "my style.css file is in root folder". E.g. if you use XAMPP, system will search it under htdocs folder. But your folder is Myshop (as you say), so please remove slash before css. Use this:

css/style.css
Deniz B.
  • 2,272
  • 1
  • 16
  • 35
0

First off if css is being written by php you need to use a .php where the .css would go.

To guarantee the path you should use something like

require_once $_SERVER['DOCUMENT_ROOT'] . 'this/from/your/url.path';

Also it is good practice to normally open the php server once, then echo everything for increased processing speed.

a coder
  • 545
  • 4
  • 23
  • i had a problem with $_SERVER. My previous query here: http://stackoverflow.com/questions/36498726/error-in-localhost/36498885?noredirect=1#comment60606993_36498885 – Ayaz Apr 09 '16 at 06:06
  • That doesn't mean that someone would read your previous question. You need to add more details sometimes. example: css very rarely has anything to do with php, so I was thinking php was dumping a bunch of css out. – a coder Apr 09 '16 at 19:23