471,616 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

Need help with OO PHP architecture problem

I can't possibly reproduce the code for this as the 2 classes in
question are about 1500 lines each and condensing is in this case
impossible due to algorithmic logic dependencies.

Let's say you have a Class A and a Class B. Let's say Class A is like
this:

class A {

var $b;

function A() {
$this->b =& new B();
}

function getOtherUniqueStuff() {
return "this is other unique stuff";
}

function displayStuffFromB() {
$html = $this->b->displayStuff('isFromA');
}

}

-----------------------------------------------------------------

Basically, Class A will display stuff from a locally instantiated B
object property.

Here is class B:

class B {

function B() {}

function displayStuff($isFromA = false) {
$html = "blah blah blah blah";
if ($isFromA) {
$html .= A::getOtherUniqueStuff();
}
return $html;
}

}

------------------------------------------------------------------

Everything is fine and dandy, except in PHP 4.3.2 I get the following
error:

Fatal error use of undefined function getotheruniquestuff

The line that produces that error is:

$html .= A::getOtherUniqueStuff();
This is why I need to get a better grip on OO PHP, I can't get past
this problem and have no solution, can someone please help?

Thanx
Phil

Jul 17 '05 #1
2 1492
Hi Phil,

phillip.s.powell wrote:
I can't possibly reproduce the code for this as the 2 classes in
question are about 1500 lines each and condensing is in this case
impossible due to algorithmic logic dependencies.


In other words, you think architecture can not work with you code. Then
why ask for help with architecture?

Your question about the example has nothing to do with architecture.
Furthermore, I happen to have php 4.3.2 running so i tried you code, but
i do not get the error. phpInfo prints this:
PHP Version 4.3.2

System Windows NT THINKPAD 5.1 build 2600
Build Date May 28 2003 15:06:05
(...)
So i am pritty damn sure this is php 4.3.2.

I added some code to my test file to make it print some things about
what your code does. This is what i get printed by my test file (viewed
as html, then copied from the browser and pasted below here):
blah blah blah blahthis is other unique stuff
NULL

a Object
(
[b] => b Object
(
)

)

I am sorry but i can't find any problem that i can help you with.

Greetings,

Henk Verhoeven,
www.phpPeanuts.org

Here is the content of my test file:

<?php

class A {

var $b;

function A() {
$this->b =& new B();
}

function getOtherUniqueStuff() {
return "this is other unique stuff";
}

function displayStuffFromB() {
$html = $this->b->displayStuff('isFromA');
}

}

class B {

function B() {}

function displayStuff($isFromA = false) {
$html = "blah blah blah blah";
if ($isFromA) {
$html .= A::getOtherUniqueStuff();
}
return $html;
}

}
$temp = new A();
print $temp->b->displayStuff(true);
print "<BR>\n";
print getType($temp->displayStuffFromB());
print "<PRE>";
print_r($temp);
print "</PRE>";
?>
Jul 17 '05 #2
Thanx anyway but I got it. I just call them both statically and that
prevented some form of overinstantiation of some kind.

Phil

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by David2511 | last post: by
reply views Thread by Julia | last post: by
3 posts views Thread by Julia | last post: by
reply views Thread by Ewart MacLucas | last post: by
10 posts views Thread by pcthug | last post: by
reply views Thread by mandarkraftware | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.