0

Hi I am new in php programming and learning this i have found a small problem.I am trying to creating a file called lib.php, where i add all my files jquery lib downloaded in /js and css files.My directory look like this:

** -practise
    + /css
    + /js
    + /images
    - /extra
      - /folder1
        - / folder1_1
            tst.php
    index.php
    navbar.php
    about.php
    blab.php
    foo.php

lib.php**

I have created a lib.php where in this file contain all files of /css and /js(jquery, w3.css,etc). And i add this file in tst.php like this include(../../../lib.php);. when i run my tst.php file in browser, the content of lib.php execute but the files of css and js dont load on browser (in inspect element --> console give me error file not found).

How can i use my lib.php in tst.php and almost in every folder... ?

Do i use something like $_server['something']./lib.php... ?

here is my lib.php:

echo '<script src="js/browjs.js"></script> ';
echo '<link rel="stylesheet" type="text/css" href="css/poperi.css">';
echo '<link rel="stylesheet" href="css/w3.css">';
echo '<link rel="stylesheet" href="css/navigt.css">';

echo " this is content for check if lib.php is loaded or not";// this line show me in tst.php
I tried my best to explain my problem and i dont know what u need more to know about this problem... TY in advance...

2
Contributors
1
Reply
13
Views
1 Year
Discussion Span
Last Post by bigtalk
0

The script and link calls (<script src="js/browjs.js"></script> and <link rel="stylesheet" type="text/css" href="css/poperi.css"> have nothing to do with php. They have to do with the browser pulling in those relative paths.
I believe your public root is "practise". You are including your js and css relative to the calling script (tst.php). This is a couple levels up from the js and css folders. To make those paths relative to the domain, put a slash in front of the paths like: <script src="/js/browjs.js"></script> and <link rel="stylesheet" type="text/css" href="/css/poperi.css">.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.