How to embed portal errors in bases


(PHP 4, PHP 5, PHP 7, PHP 8)

basename - Returns the last part of the name of a path specification


basename (string, string =?): string

This function returns the last part of the name from a transferred character string containing the path to a file or directory.


basename () only works with the input string and does not consider the actual file system or path components such as "".


basename () respects the language settings (locale); if it is to recognize the correct name base in paths with a multi-byte character set, the appropriate language setting (locale) must be set with the setlocale () function.

Parameter list

One path.

Under Windows, both the slash () and the backslash () are used as separators for path specifications. On other operating systems, however, only the slash ().

If the part of the name ends with, it is also cut off.

Return values

Returns the final name of the passed.


Example 1 basename () example

The example shown above produces the following output:

1) sudoers 2) sudoers.d 3) passwd 4) etc 5). 6)

See also

  • dirname () - Returns the path of the parent directory
  • pathinfo () - Returns information about a file path
stephane dot fidanza at gmail dot com
zandor_zz at yahoo dot it
swedish boy
KOmaSHOOTER at gmx dot de
pvollma at pcvsoftware dot net
KOmaSHOOTER at gmx dot de
crash at subsection dot org dot uk
amitabh at NOSPAM dot saysnetsoft dot com
poop at poop dot com
stocki dot r at gmail dot com
hello at haroonahmad dot co dot uk
pai dot ravi at yahoo dot com
adrian at foeder dot de
Muhammad El-Saeed muhammad at elsaeed dot info
daijoubu_NOSP at M_videotron dot approx
wibgates dot kenneth at gmail dot com
gandung at ppp dot cylab dot cmu dot edu
KOmaSHOOTER at gmx dot de