取消定义的功能 [英] undefining functions

查看:81
本文介绍了取消定义的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个为我制作的每个网站运行的主脚本,并且它有一套标准的

功能集,但有时我会想要覆盖该功能以获得

特定网站,但如果我重新定义该网站,PHP会抱怨

覆盖功能。由于这是一个很好的警告,我不想删除

它,但我想要取消定义再次定义之前的功能。


喜欢:function_undefine(" drawbox");


或类似的东西。


有人有什么建议吗?


-

Sandman [.net]

I have a master-script that runs for every site I make, and it has a standard
set of functions, but sometimes I would want to override that function for a
particular site, but if I redefine it for that site, PHP will complain about
overriding functions. Since that''s a good warning, I wouldn''t want to remove
it, but I would want to "undefine" a function before defining it again.

like: function_undefine("drawbox");

Or something like that.

Anyone got any suggestions?

--
Sandman[.net]

推荐答案



你不想定义,取消定义和重新定义函数或

你有cpu周期浪费吗? br />

将您的functions.inc拆分为模块化实体,您可以根据请求加载
。最后加载特定于站点的东西。


request_once(''func1.inc'');

request_once(''func2.inc'' );

request_once(''func3.inc'');

request_once(''spec1.inc'');

request_once( ''spec2.inc'');


Sandman写道:

you don''t want to define, undefine and redefine functions or
do you have cpu cycles to waste?

split your functions.inc into modular entities that you can
load on request. load the site-specific things at the end.

request_once(''func1.inc'');
request_once(''func2.inc'');
request_once(''func3.inc'');
request_once(''spec1.inc'');
request_once(''spec2.inc'');


Sandman wrote:
我有一个主脚本,每个都运行我制作的网站,它有一套标准的功能,但有时我想覆盖特定网站的功能,但如果我重新定义该网站,PHP会抱怨
覆盖函数。由于这是一个很好的警告,我不想删除它,但我想要取消定义再次定义之前的功能。

喜欢:function_undefine(" drawbox");

或类似的东西。

任何人都有任何建议?
I have a master-script that runs for every site I make, and it has a standard
set of functions, but sometimes I would want to override that function for a
particular site, but if I redefine it for that site, PHP will complain about
overriding functions. Since that''s a good warning, I wouldn''t want to remove
it, but I would want to "undefine" a function before defining it again.

like: function_undefine("drawbox");

Or something like that.

Anyone got any suggestions?






Sandman写道:
Sandman wrote:
有人有任何建议吗?




<?php

class Master {

function func1(){echo''func1'';返回true; }

函数func2(){echo''func1'';返回true; }

}

class Site_X {

function func1(){echo''X1'';返回true; }

函数func2(){echo''X1'';返回true; }

}


if(Master :: func1())Site_X :: func2();

?>

-

如果每个人都读到USENET会更好:邮件地址:
http://www.catb.org/~esr/faqs/smart-questions.html :有效:
http://www.netmeister.org/news/learn2quote2 .html :" text / plain" :
http://www.expita.com/nomime.html:到10K字节:



<?php
class Master {
function func1() { echo ''func1''; return true; }
function func2() { echo ''func1''; return true; }
}
class Site_X {
function func1() { echo ''X1''; return true; }
function func2() { echo ''X1''; return true; }
}

if (Master::func1()) Site_X::func2();
?>
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :


" Sandman" < mr@sandman.net>在留言中写道

新闻:先生********************** @ news.fu-berlin.de ...
"Sandman" <mr@sandman.net> wrote in message
news:mr**********************@news.fu-berlin.de...
我有一个为我制作的每个网站运行的主脚本,并且它有一个
标准的函数集,但有时我想要为
a特定网站覆盖该函数,但是如果我为该网站重新定义它,PHP将抱怨
关于覆盖函数。由于这是一个很好的警告,我不想要
删除它,但我想要取消定义再次定义之前的功能。

喜欢:function_undefine(" drawbox");

或类似的东西。

任何人都有任何建议?
I have a master-script that runs for every site I make, and it has a standard set of functions, but sometimes I would want to override that function for a particular site, but if I redefine it for that site, PHP will complain about overriding functions. Since that''s a good warning, I wouldn''t want to remove it, but I would want to "undefine" a function before defining it again.

like: function_undefine("drawbox");

Or something like that.

Anyone got any suggestions?




如果您的_sure_这是您想要的(请记住所涉及的开销

)解析

主脚本功能,即使它们没有被使用),查看变量

函数。


我相信这是可能的(如果我',请纠正我我错了)...


主脚本:


函数foo_default()

{

echo''blah blah blah'';

}



If your _sure_ this is what you want (bearing in mind the overhead involved
in parsing the
master-script functions even though they are not used), look into variable
functions.

I believe this is possible (correct me if i''m wrong)...

in master-script:

function foo_default()
{
echo ''blah blah blah'';
}


这篇关于取消定义的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆