Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP object recusion issue
Old 04-06-2009, 09:20 PM PHP object recusion issue
Skilled Talker

Posts: 62
Name: Daniel
Trades: 0
okay, say we're going with this code below

<?php

class Foo {
function __construct(&$Bar) {
$this->Bar = &$Bar;
}
}

class Bar {
function __construct() {
$this->Variable = "this";
$this->Foo = new Foo($this);
}
}

$Bar = new Bar();

echo "<pre>";
var_dump($Bar);

?>

When Bar is instantiated, it also instantiates Bar and passes everything in. Meaning when Foo is instantiated and Bar is passed in, $Bar->Foo->Bar->Variable is equal to "this".

Is there any way to stop a certain variable from being passed down like this?

Did it even make sense?

The reason I'm asking is because I'm concerned with performance. Theres an absolute ton of this going on in the framework I've been working on. Should I even be concerned with this?
castis is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-07-2009, 05:23 PM Re: PHP object recusion issue
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
What is your goal with this setup? It might be better to suggest a means of achieving your goal since the relationship here doesn't immediately strike me as being the most logical way of achieving a task.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-07-2009, 05:39 PM Re: PHP object recusion issue
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
circular dependencies will only lead to pain and suffering.

Like Jeremy said, it'll be more useful to understand what it is you are trying to do.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 04-07-2009, 05:59 PM Re: PHP object recusion issue
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Whew - I'm dizzy!
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP object recusion issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13155 seconds with 12 queries