I am trying to include my JS file, which includes all core Javascript files in a PHP file, but I cannot get the relative/root path to work, so I could use it across all the pages which are located in sub folders etc.
Here is the structure:
In Dashboard I have this:
In folder family
I have a file called addJob.php
where I am trying to include a file bottomscripts.php
which is in Dashboard/PHP/views/JS_includes/
.
I have to use these across all the pages so how can I set the path? I tried using this:
<?php
define('BASE_URL', 'http://localhost/Hoidja.ee/Dashboard/');
echo ('<script src='.BASE_URL.'assets/js/gsap/main-gsap.js"></script>');
echo ('<script src='.BASE_URL.'assets/js/resizeable.js"></script>');
echo ('<script src='.BASE_URL.'assets/js/neon-api.js"></script>');
echo ('<script src='.BASE_URL.'assets/js/neon-custom.js"></script>');
?>
But this gives me forbidden error. I also tried $_SERVER['DOCUMENT_ROOT']
but this gives me failed to load local resource.
<?php
$basePath = $_SERVER['DOCUMENT_ROOT'].'/Hoidja.ee/Dashboard/';
echo ('<script src='.$basePath.'assets/js/gsap/main-gsap.js"></script>');
echo ('<script src='.$basePath.'assets/js/resizeable.js"></script>');
echo ('<script src='.$basePath.'assets/js/neon-api.js"></script>');
echo ('<script src='.$basePath.'assets/js/neon-custom.js"></script>');
?>