父对象 [英] Parent Objects

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

问题描述

我有


class thechild {

function sayTest()

{

parent ::测试(); //这个对吧???

}

}


class theparent {

功能测试()

{

echo" test";

}

function __construct()

{

$ e = new thechild();

$ e-> sayTest();

}

}


我如何让它工作?我试图获得一个班级(A)到

在其中创建另一个班级(B),但是班级B必须能够从班级调用一个函数
A.任何想法?


谢谢

Paul Jenkins
www.pjenkins.co.uk

解决方案

e = new thechild ();


e-> sayTest();

}

}


如何让它工作?我试图获得一个班级(A)到

在其中创建另一个班级(B),但是班级B必须能够从班级调用一个函数
A.任何想法?


谢谢

Paul Jenkins
www.pjenkins.co.uk


paul.j写道:
< blockquote class =post_quotes>
我有


class thechild {

function sayTest()

{

parent :: test(); //这个对吧???

}

}


class theparent {

功能测试()

{

echo" test";

}

function __construct()

{


I have

class thechild{
function sayTest()
{
parent::test(); // this right???
}
}

class theparent{
function test()
{
echo "test";
}
function __construct()
{
$e = new thechild();
$e->sayTest();
}
}

How do i get this to work ? I am trying to get a one class (A) to
create another class (B) within it, but the class B must be able to
call a function from class A. Any ideas?

Thanks
Paul Jenkins
www.pjenkins.co.uk

解决方案

e = new thechild();


e->sayTest();
}
}

How do i get this to work ? I am trying to get a one class (A) to
create another class (B) within it, but the class B must be able to
call a function from class A. Any ideas?

Thanks
Paul Jenkins
www.pjenkins.co.uk


paul.j wrote:

I have

class thechild{
function sayTest()
{
parent::test(); // this right???
}
}

class theparent{
function test()
{
echo "test";
}
function __construct()
{


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

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