domingo, 18 de enero de 2009

I'm gonna start posting bits of PHP or other coding langs here so I can remember them when I need them.

First:

how to get the filename of a PHP script ( without the server or anything )

echo end(explode('/',$_SERVER['PHP_SELF']));

now a way to get just where the script is being executed the main path of the server
would be:

$scriptname=end(explode('/',$_SERVER['PHP_SELF']));
$htmlpath ='http://'.preg_replace('/'.$scriptname.'/',"",$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']);
echo $htmlpath;

No hay comentarios: