Re: include() and duplicate function definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 3 Nov 2010 19:53:52 +0800, David Nelson <commerce@xxxxxxxxxxxxxx> wrote:
Hi, :-)

On Wed, Nov 3, 2010 at 19:29, Peter Lind <peter.e.lind@xxxxxxxxx> wrote:
That's not going to happen. My point was you could check in the original
file if the function is defined and if not then define it.

OK, thanks, Thijs and Peter, it looks like I'm trying to do something
that is not currently possible in PHP. Time for some lateral thinking.
:-)

David Nelson

David,

I re-read your original post. And noticed you include the function inside your child action.php Is there a special reason for that? You want to overwrite the original function in a child theme. probably to get different functionality. So why do you need the original function?

Just create your action.php and define the same function.


// include '../sometheme/functions/actions.php';

function foo($arg_1, $arg_2, /* ..., */ $arg_n) {
    echo "All my new code.\n";
}

It's code duplication. But i don't think themes should have dependencies to one an other.
You could also create a actions.php file outside the themes folder.

wp-content/shared-functions/action.php

And then in your themes do:

theme 1

include "shared-function/action.php";

foo();


theme 2

include "shared-function/action.php";

foo();

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux