How to know the name of the folder containing the php file?

I have a problem, you need to make php output into a variable the name of the folder in which it is located. Did you try the command __DIR__ but it display the full path of the folder, and I need only the folder name. Information in Google not found. Thanks in advance)
April 19th 20 at 12:16
3 answers
April 19th 20 at 12:18
Solution
<?php
echo basename(__DIR__);
Thank you so much, helped! - Jaleel_Wyman commented on April 19th 20 at 12:21
April 19th 20 at 12:20
And in the PHP documentation to look not tried? dirname()
Thanks, but I need only the name of the last folder and not the entire path to it. Or I something don't you understand? - Jaleel_Wyman commented on April 19th 20 at 12:23
@Jaleel_Wyman, combo with https://www.php.net/manual/ru/function.basename.php - taya.Morar commented on April 19th 20 at 12:26
Why did you accept this answer if it does not suit you? - leatha.Little commented on April 19th 20 at 12:29
@taya.Morar, Thanks, I'll try to do) - Jaleel_Wyman commented on April 19th 20 at 12:32
April 19th 20 at 12:22
Did you try the command __DIR__ but it display the full path to the php file

Didn't your mother tell a child that lying is bad?
The bcm? Just a newbie in php) - Jaleel_Wyman commented on April 19th 20 at 12:25
VSM __DIR__ outputs the path to the folder, not the file - leatha.Little commented on April 19th 20 at 12:28
@Stacy.Little, Yes. Only will so Sate/Components/Derictory/ , and me only need the last folder. - Jaleel_Wyman commented on April 19th 20 at 12:31
so it is necessary to write.
because the "folder name" can mean the full path and the last parting.
and neither is lying in the folder the file is not relevant - leatha.Little commented on April 19th 20 at 12:34
@Stacy.Little, litter, a little not so wrote. - Jaleel_Wyman commented on April 19th 20 at 12:37
well, what I wrote, and got it
for the future think asked
then Google will immediately give you the answer to the question - leatha.Little commented on April 19th 20 at 12:40
@Stacy.Little, In Google I have written is correct, and that he proposed to write domain and I only want the last folder. Anyway, I already fixed the issue and have already given the answer, just need to check. - Jaleel_Wyman commented on April 19th 20 at 12:43
Don't you think you have a problem with the logic?
If you Google gave the wrong answer, then you asked the wrong question.
So no need to bleat that " Google I wrote the right thing."
I would have written "tag to the last folder", and got the answer to your question - leatha.Little commented on April 19th 20 at 12:46
@Stacy.Little, don't know if you already made like this. If you are good at Google, and nick, you have said that you are “a fan of php,” why couldn't you have done some on this forum, to find in Google the answer to send. (not to offend here) - Jaleel_Wyman commented on April 19th 20 at 12:49
because you're already being rude
get a slaves first and then send them to Google - leatha.Little commented on April 19th 20 at 12:52
Actually I have not started it. - Jaleel_Wyman commented on April 19th 20 at 12:55
well, learn to use search then - leatha.Little commented on April 19th 20 at 12:58
Damn, just Google found nothing. So I decided to write here. Got the answer. And everything is clear) - Jaleel_Wyman commented on April 19th 20 at 13:01
Not clearly. enough with the shame and tell everyone what a helpless klutz - leatha.Little commented on April 19th 20 at 13:04
Clearly not Vice versa. Why are you here yourself Somavia smart doing? I got an answer and all. You then continue trying with some words nothing to talk about. I outlined the essence of correctly and got the right answer! And there is no need to call names. And it's not my shame, it is clear on moyom the account is written, I'm primarily a coder and then cucut programmer here and asked people who better know about it. We have 2 hours to find out it is not clear that! The matter was correctly set out, and I got the answer. And we're not in fact talking! - Jaleel_Wyman commented on April 19th 20 at 13:07
You continue to disgrace :)
Well, go on, if so itching - leatha.Little commented on April 19th 20 at 13:10
Ha, I still continue and may already be enough to prove his supposedly right - Jaleel_Wyman commented on April 19th 20 at 13:13

Find more questions by tags PHP