PHP » PYTHON |
login |
register |
about
|
import os.path #__file__ is a variable representing the name of the file running. absolute_path = os.path.abspath(__file__) dirname = os.path.dirname(absolute_path) basename = os.path.basename(absolute_path) extension = os.path.splitext(absolute_path)[-1] # return ".py" filename = __file__ print absolute_path print dirname print basename print extension print filename pathinfo(PHP 4 >= 4.0.3, PHP 5) pathinfo — Returns information about a file path Description
mixed pathinfo
( string $path
[, int $options= PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME
] )
pathinfo() returns an associative array containing information about path . Parameters
Return ValuesThe following associative array elements are returned: dirname, basename, extension (if any), and filename. If options is used, this function will return a string if not all elements are requested. Changelog
Examples
Example #1 pathinfo() Example
<?php The above example will output: /www/htdocs index.html html index
Notes
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|