Hi all,
I have seen code of the form:
if(file_exists("foo.php")
include("foo.php");
else
include("blah.php");
As far as I know, this is perfectly legal in php. What I was wondering was is it possible to do the following in in-line code in PHP?
if(file_exists("foo.php")
// contains a specialised version of myFoo function
include("foo.php");
else
{
// define the default function here
function myFoo($param)
{
// do something here
}
}
So in other words I want to be able to define a function in my PHP code only if the specialised version does not exist. I need to do this without the use of classes and inheritance if possible, and I can't include a second file at this stage, just wondering if the above code is legal or not.
Thanks in advance for your thoughts and time.
Regards,
darkagn