PHP magic constants
PHP program name=/home/www/miksup.100webspace.net/pdf_adobe_pdf/program_name.php
PHP programname=/home/www/miksup.100webspace.net/pdf_adobe_pdf/program_name.php
PHP file name=/home/www/miksup.100webspace.net/pdf_adobe_pdf/program_name.php
PHP filename=/home/www/miksup.100webspace.net/pdf_adobe_pdf/program_name.phpPHP program name
well to get the PHP file name the user clicked on use this code
$filename=preg_replace('/.*\//',"",__FILE__);
echo "file=$filename";
And bingo the file name is displayed
program_name.php
Path to PHP program name
To get the path to the PHP file name the user clicked on use this code
$filenamepath=preg_replace("/\/[^\/]*\$/","",__FILE__);
echo $filenamepath;
And bingo the path to the filename is displayed
/home/www/miksup.100webspace.net/pdf_adobe_pdf
To get an array of the sub-directorys down to your
program name use this PHP code
and this is the array you will get
- home
- www
- miksup.100webspace.net
- pdf_adobe_pdf
- program_name.php
PHP function or subroutine name
To get the name of the PHP function your in use this code
$functionname=__FUNCTION__;
echo "this functions name is ".$functionname."()";
echo "this functions name is ";
echo __FUNCTION__."()";
And when we run it the output looks like this
this functions name is foo()
this functions name is foo()
PHP line number
To get the current line number of the PHP code use this
PHP line number=112
PHP linenumber=113
PHP class and PHP method
And for object oriented stuff use these
echo "PHP name of class of object=".__CLASS__."";
echo "PHP name of object function=".__METHOD__;
Here is the object stuff at work
PHP name of class of object=
PHP name of object function=