PHP是不是没法再class的外面定义method?
那也太不方便了。:mrgreen: 啥意思???? 回复 2# bikong0411就是说我定义一个类(foo),
然后定义了几个函数(foo_method_01(), foo_method_02()),但是这2个函数比较长,我想单独放在一个文件里面不想和foo放在一起。 可以啊
$ cat b.php
<?php
function t()
{
echo "W";
}
$ cat a.php
<?php
require 'b.php';
class A
{
function test()
{
t();
}
}
$a=new A();
$a->test();
$ php a.php
W 回复 4# bikong0411
这个明显不算啊,你的test是在class内部定义好的,然后只是调用了一下外部的函数,这个不能算是在class外面定义test吧。
回复 5# fender0107401
x,我说的是外面定义个t,哪说是test了
回复 6# bikong0411
我就想去外边定义test,哈哈。 :mrgreen:
可以用继承。 别钻牛角尖
页:
[1]