A função SplFileInfo::getRealPath() é uma função embutida da Biblioteca PHP Padrão (SPL) em PHP que é usada para obter o caminho absoluto do arquivo.

Sintaxe:

int SplFileInfo::getRealPath( void )

Parâmetros: esta função não aceita nenhum parâmetro.

Valores de retorno: esta função retorna o caminho para o arquivo em caso de sucesso.

Os programas abaixo ilustram a função SplFileInfo::getRealPath() em PHP:

Programa 1:

<?php
  
// PHP Program to illustrate 
// Splfileinfo getRealPath function
  
$file = new SplFileInfo("gfg.txt");
$gfg = $file->getRealPath();
  
// Print real path if exist
var_dump($gfg . "</br>");
  
$file = new SplFileInfo(__FILE__);
$gfg = $file->getRealPath();
  
// Print real path if exist
var_dump($gfg);
  
?>

Saída:

string(26) "/var/www/html/gfg.txt
" string(22) "/var/www/html/cons.php" 

Programa 2:

<?php
  
// PHP program to use array to check multiple files
$GFG = array (
    "/home/rajvir/Desktop/GeeksforGeeks/dummy.php",
    "/home/rajvir/Desktop/gfg_code.cpp",
    "/var/www/html/gfg1.php",
    "dummy.php"
);
   
foreach ($GFG as &$file_name) {
       
    // Create new SplFile Object
    $file = new SplFileInfo($file_name);
  
    $gfg = $file->getRealPath();
  
    // Print real path if exist
    var_dump($gfg. "</br>");
}
?>

Saída:

string(49) "/home/rajvir/Desktop/GeeksforGeeks/dummy.php
" string(38) "/home/rajvir/Desktop/gfg_code.cpp
" string(5) "
" string(28) "/var/www/html/dummy.php

Referência: http://php.net/manual/en/splfileinfo.getrealpath.php