justin7410 Posted November 19, 2013 Share Posted November 19, 2013 Hey guys, i am working for the first time on a localhost. at the moment i have an index file and i want to start splitting the page up to make this website dynamic. at first i tried to take my <head>.( <meta> / <title> tags , ) and include() them with a header.php file I am not sure if this is something i can even do or if my path is just not correct. i have my wamp on my C drive and its all through a www folder path. i then created an include file inside the www, where all files that i would use dynamically would be placed( header, footer, etc..) i tried two paths: include('include/header.php'); - didn't work i then removed the folder and had all the php files in one folder. include('header.php'); none of this works , the css of the page doesnt show up. i then replace the <head> info back inside the index, and all works fine. any suggestions ? Quote Link to comment https://forums.phpfreaks.com/topic/284041-how-to-make-include-function-work-on-localhost/ Share on other sites More sharing options...
JIXO Posted November 19, 2013 Share Posted November 19, 2013 (edited) It's always a good practice to set a document root, look here. defined('SITE_ROOT'') ? NULL : define('SITE_ROOT', 'C:\Apache24\htdocs\project''); // Or defined('SITE_ROOT'') ? NULL : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT'].'\project''); Then refering to any file will be simple require SITE_ROOT.'\includes\file.php'; As for the style sheets ..... <?php defined('SITE_STYLE'') ? NULL : define('SITE_STYLE', SITE_ROOT.'\css''); ?> <html> ... <link rel="stylesheet" type="text/css" href="<?php echo SITE_STYLE.'\pagestyle.css'; ?>" /> Edited November 19, 2013 by JIXO Quote Link to comment https://forums.phpfreaks.com/topic/284041-how-to-make-include-function-work-on-localhost/#findComment-1458922 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.