0

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.

2
  • Care to share an example of your code? :-) Commented Aug 9, 2010 at 11:05
  • It's not clear what are you trying to do Commented Aug 9, 2010 at 11:08

1 Answer 1

3

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.

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.