PHP pathinfo() Function

PHP pclose() Function
PHP parse_ini_string() Function

In this article, you will learn how to get the following information in PHP.

  • Directory name
  • Basename
  • Extension of file
  • Filename

PHP pathinfo() returns the above information for a path in PHP.

what is the syntax of the PATHINFO function in php?

pathinfo(path, options)
ParameterDescription
pathRequired. Specifies the path to be checked
optionsOptional. Specifies which array element to return. If not specified, it returns all elements.Possible values:PATHINFO_DIRNAME – return only dirnamePATHINFO_BASENAME – return only basenamePATHINFO_EXTENSION – return only extensionPATHINFO_FILENAME – return only filename
PHP PATHINFO() method

examples of the PATHINFO function

Example 1. In this example, we get information about a file path.

<?php
print_r(pathinfo("/testweb/test.txt"));
?>
PHP pclose() Function
PHP parse_ini_string() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top