TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-27-2009, 04:58 PM   #1 (permalink)
The Wanderer
 
Join Date: Jul 2009
Posts: 5
Thanks: 0
sohdubom is on a distinguished road
Default Object Association doubt.

Hi. I was wondering which one of the samples below would be right to set as object association.

===snippet 01===
PHP Code:
$p1 = new Person(10'John Doe''31/07/1967');
$a1 = new Account;
$a1->accountOwner $p1;
var_dump($a1);
unset(
$a1);
echo isset(
$p1) ? '$p1 isset' '$p1 is not set'// Person is still set 
=============

===snippet 02===
PHP Code:
$a1 = new Account;
$a1->accountOwner = new Person(10'John Doe''31/07/1967');
var_dump($a1);
unset(
$a1);
// both Account and Person are unset here 
=============

In snippet 01 objects Person and Account are created separately and then I reference assign Person to Account, $a1->accountOwner = $p1;

In snippet 02 I reference assign Person to Account, $a1->accountOwner = new Person(10, 'John Doe', '31/07/1967'); so that I don't have $p1 explicitly assigned.

The doubt is: which one is considered to be Association?

Thanx in advance
sohdubom is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the Clone Construct to Clone an Object Wildhoney Advanced PHP Programming 5 01-29-2013 11:51 AM
Using the factory pattern (mad rantings of a mind without coffee) sketchMedia Advanced PHP Programming 35 09-25-2009 11:05 AM
Object Aggregation Jenski Advanced PHP Programming 2 08-07-2008 09:53 AM
array to object Gibou Advanced PHP Programming 11 03-24-2008 06:07 PM
Object methods suddenly lagging? RobertK Advanced PHP Programming 9 01-11-2008 01:38 PM


All times are GMT. The time now is 02:11 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design