Dynamic URL inside PHP Include?

Hello,

I am trying to place a dynamic file path inside a PHP include. It is in Wordpress and I am using ABSPATH. Here is my code where {dynamic_path} is what I want to change. I currently update non PHP parts of the page with another PHP script but I know you can’t drop PHP inside PHP. I’m stumped.

<?php include(ABSPATH."[b]{dynamic_path}[/b]/params.php") ?>

The important question I have to ask, what are you trying to do. If you are using the absolute path, it is specific. Your file is likely in a specific location as well. So, why would you need to dynamically route a path using a combination of absolute and dynamic.

I think the logic you are using may be ill thought out, or at least shortsighted.

Amen to that, though I really don’t know what’s the issue… just insert anything you want instead of {dynamic_path} like you said.

Well, also, if you mean that you have a FOLDER name that changes during the site’s use and you want
to access various paths that way, you must make sure that your “/” are correct between the folders.

Your code: include(ABSPATH."{dynamic_path}/params.php") may not be placing the slash between
the absolute path and the dynamic path. I suggest you DEBUG the code. You can do that by testing it
with this code. Just replace the above line with this one:
[php]
die(ABSPATH."{dynamic_path}/params.php")
[/php]
What that will do is force the page to end at that point and show you what is being placed there. It will
show you what is really being included at that point. Then, you can see where it is failing and alter it as
needed…

Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service