How to edit js/swf file path in my php page using PHP code. Path is not unique it is varying. I have to search these file path and replace it.
1 Answer
Although i'm not entirely sure what you're trying to do, you could try this?
I once had a similar problem with a design where my includes / css / js, etc got out of sync when the path was above the root and i was using relative links to call a constantly included header.php file.
I used this to cope with the paths and add a "../" prefix to include the file properly and to save having to check each page afterwards.
$path = $_SERVER['REQUEST_URI'];
$level = count(explode("/",$path));
$level = $level-1;
$prefix = "";
for ($i = 1; $i < $level; $i++) {
$prefix .= "../";
}
eg:
include($prefix."header.php");
<script src="<?=$prefix.JS_FOLDER.$js_filename?>" type="text/javascript"></script>
Let me know if that helps.