Documentación offline PHP master

SplFileInfo::getRealPath

master Ver versión oficial en línea Licencia CC-BY-3.0Descargado el 2026-08-02

En esta página

SplFileInfo::getRealPath

Obtiene la ruta absoluta al fichero

Descripción#

public SplFileInfo::getRealPath(): string
```php

Este método expande todos los enlaces simbólicos, resuelve las referencias relativas y retorna la ruta real al fichero.

## Parámetros

Esta función no contiene ningún parámetro.

## Valores devueltos

Devuelve la ruta al fichero, o `false` si el fichero no existe.

## Ejemplos

Ejemplo de `SplFileInfo::getRealPath`
getRealPath()); $info = new SplFileInfo('/tmp'); var_dump($info->getRealPath()); $info = new SplFileInfo('/I/Do/Not/Exist'); var_dump($info->getRealPath()); $info = new SplFileInfo('php://output'); var_dump($info->getRealPath()); $info = new SplFileInfo(""); var_dump($info->getRealPath()); ?>

```php

Resultado del ejemplo anterior es similar a:

string(28) "/private/tmp/phptempfile.php"
string(12) "/private/tmp"
bool(false)
bool(false)
string(12) "/private/tmp"

Véase también#

SplFileInfo::isLink, realpath