PHP realpath() function and example


 

PHP realpath() function and example

In this part of the tutorial we will learn about the function realpath() in context of file handling. And also we will see the example related to the realpath() function

In this part of the tutorial we will learn about the function realpath() in context of file handling. And also we will see the example related to the realpath() function

Syntax for PHP realpath() Function

string realpath(file_path)

  • realpath() function  returns  absolute path  from the root(/ in linux and c:\ in widow) in string form.
  • It  interprets  all the \ used for the relative  path and the symbolic link
  • Then returns the absolute path.
  • On failure it returns FALSE value.

PHP realpath() Function with Example

Code of PHP realpath() Function
<?php
echo realpath("aa.txt");
?>
Output
C:\xampp\htdocs\filehandling\aa.txt

Ads