Hello Alll,
I seem to remember having read somewhere that there is a facility for calling a function with additional information beforehand which shows which include file the function is held in.
Example:
file xyz.php holds function getHello();
Main file
<?php
include("xyz");
echo(<method>getHello());
?>
Has anyone come across this ? Are they able replace the <method> text ?
I realise the other method could be echo(getHello()); // function in xyz.php
Thanks
Mark
Calling function with the "include file name"
Moderator: General Moderators
-
markbeadle
- Forum Commoner
- Posts: 29
- Joined: Tue Dec 02, 2003 2:50 am
- Location: Aachen, Germany
First of all, you have some bad things in your code;
if you want to replace <method> by getHello(), use str_replace
look at the PHP manual under strings for it
Code: Select all
<?php
include("xyz.php"); //You forgot the .php extension
echo "<method>getHello()"; //you forgot " and "
?>look at the PHP manual under strings for it
__FILE__ and __LINE__ might be what you are looking for.
Note that you can't build a single use-anywhere function to wrap that up: they'll always return the custom function location and not the location where you execute the fn.
I use this quite a lot for debugging. First I build a $location var with the above two constants, and then pass it in to a $monitor logging object. Very useful if your scripts are composed of multiple files.
Note that you can't build a single use-anywhere function to wrap that up: they'll always return the custom function location and not the location where you execute the fn.
I use this quite a lot for debugging. First I build a $location var with the above two constants, and then pass it in to a $monitor logging object. Very useful if your scripts are composed of multiple files.
-
markbeadle
- Forum Commoner
- Posts: 29
- Joined: Tue Dec 02, 2003 2:50 am
- Location: Aachen, Germany