wordpress - How to get the current project name in php code?


I'm new to php. I want to use function get project name but i don't know how. Example:


project name is "first_wordpress".

Pleas help me.

Thanks! Sorry for my english.




This is hard to get because of some reasons:

  • Project name may change
  • Path may be different in your local system or in your web server, so you cant substring your path

What I suggest is to have a config file with some values that are constant in your project and that are going to stay always the same, like your project name.

I would create this:



const PROJECT_NAME = 'first_wordpress';
const SOME_OTHER_CONST = 'whatever';
const FOO = 'bar';


and then include it in the file you need it, for example


include 'constants.php';
echo 'This is my project name '.PROJECT_NAME;

I guess that you are using Wordpress, so your constant file, or config, is called wp-config.php. Try that!

Edit: a user of php.net brings this solution.

I hope it helps!

People are also looking for solutions to the problem: php - Remove all numeric index to have an assoc array only


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.