0

I have a Folder name called Test2. Inside Test2 contains "universal.php" and "universal.css". Also inside Test2, is another folder called article. Inside article, contains a file called template.php. With template.php, I am trying to require_once universal.php. I am using this:

<?php
       require_once "../universal.php";
?>

This is displaying the PHP, but not the CSS that goes with the file. universal.php is linked to universal.css. Whenever, I make a new file inside of test2, and require_once using just this:

<?php
require_once "universal.php";
?>

it works. universal.php is displayed with the css properties of universal.css. How do I make it so that template.php gets the css properties of universal.css?

4
  • please show code of css include. Commented Jan 6, 2016 at 6:03
  • @DivyeshSavaliya I am not including CSS in template.php. Just universal.php. universal.css is linked to universal.php Commented Jan 6, 2016 at 6:08
  • Inline the CSS or adjust the path of the CSS file according to current directory where you are including the file. (Hint: In universal.php, set the path for css as ../universal.css as you are going to access the file from the inner directory). Commented Jan 6, 2016 at 6:08
  • try DIR directory... as like require_once DIR."\universal.php"; Commented Jan 6, 2016 at 6:09

1 Answer 1

2

in universal.php try ../universal.css because you are calling universal.php inside template.php so directory occurs for template.php

Sign up to request clarification or add additional context in comments.

3 Comments

universal.css and universal.php are in the same folder, when I require_once in universal.php for ../universal.css the css still doesn't show up in the template
Whenever I do this, the actual CSS code shows up on the page, the CSS properties don't change the HTML properties of the universal.php
put them inside a style tag <style> h1 {color:red;} p {color:blue;} </style>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.