EspañolDeutschFrançaisItalianoPortuguêsРусскийΕλληνικά日本語中文(简体)हिन्दी; हिंदीالعربية
Configura come lingua predefinita
Domande di PF - Cose da fare

Ottenere il nome del file PHP corrente

Come posso ottenere dinamicamente il nome del file PHP che sono in esecuzione??

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 fa frequenti 7 anni
2 Risposte
Miglior risposta

Semplicemente utilizzare la costante PHP nativo __FILE__. Ovunque nel codice è possibile accedere. Provare a stampare da schermo e vedrete:

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 ha detto rende 7 anni

Se quello che vuoi è semplicemente sapere il nome del file PHP indipendentemente dal percorso completo, tramite la costante file del modulo

basename(__FILE__);

e restituisce solo il nome dello script in esecuzione.

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 ha detto rende 7 anni