T
T
Type Programmer2020-04-16 10:32:13
PHP
Type Programmer, 2020-04-16 10:32:13

How to find out the name of the folder in which the php file is located?

I have a problem, I need to make sure that php displays the name of the folder in which it is located in a variable. I tried the __DIR__ command but it displays the full path to the folder, and I only need the folder name. Couldn't find any information on google. Thanks in advance)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nokimaro, 2020-04-16
@Oleg2002pr

<?php
echo basename(__DIR__);

R
Rsa97, 2020-04-16
@Rsa97

Have you tried looking in the PHP documentation? dirname()

F
FanatPHP, 2020-04-16
@FanatPHP

I tried the __DIR__ command but it displays the full path to the php file,

Didn't your mom tell you when you were a kid that it's wrong to lie?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question