EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
Definir como idioma padrão
Perguntas de PF - Fórum

Obter o nome do arquivo PHP atual

¿Cómo puedo obtener dinámicamente el nombre del archivo PHP que estoy ejecutando?

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
MaxPower Será que perguntou 7 anos
2 Respostas
Melhor resposta

Simplemente usa la constante nativa de PHP __FILE__. En cualquier lugar del código puedes acceder a ella. Prueba a imprimirla por pantalla y lo verás:

echo __FILE__;

 

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
Juanr disse faz 7 anos

Se o que como é simplesmente saber o nome do arquivo PHP sem importar a rota completa, usa o Macrospara constante no seguinte formulário

basename(__FILE__);

y te devuelve solamente el nombre del script que estás ejecutando.

Share on Facebook Tweet about this on Twitter Share on Google+ Pin on Pinterest Share on Reddit Share on VK Share on StumbleUpon Share on Tumblr Share on LinkedIn Email this to someone Print this page
Maria_rg disse faz 7 anos