Nathan Nobbe wrote:
On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:
Personally I'd use a static method in this instance.
thats what i recommended.
If you need to create
an instance of the class you can do so in the static method and that way it
will get destroyed when the function is
Stut schreef:
Nathan Nobbe wrote:
On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:
Personally I'd use a static method in this instance.
thats what i recommended.
If you need to create
an instance of the class you can do so in the static method and that
way it
will get destroyed when
Jochem Maas wrote:
Stut schreef:
Nathan Nobbe wrote:
On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:
Personally I'd use a static method in this instance.
thats what i recommended.
If you need to create
an instance of the class you can do so in the static method and that
way it
Stut schreef:
Jochem Maas wrote:
Stut schreef:
Nathan Nobbe wrote:
On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:
Personally I'd use a static method in this instance.
thats what i recommended.
If you need to create
an instance of the class you can do so in the static method and
Nathan Nobbe wrote:
Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.
im pretty sure constructors return an object instance:
php class Test { function __construct() {} }
php var_dump(new Test());
object(Test)#1 (0) {
}
Anup Shukla schreef:
Nathan Nobbe wrote:
Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.
im pretty sure constructors return an object instance:
php class Test { function __construct() {} }
php var_dump(new Test());
On Jan 30, 2008 5:56 AM, Stut [EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
You posted a singleton pattern.
no, what i posted was a simple factory pattern.
if you invoke it twice there will be 2 instances of Test in memory,
eg. not singleton.
$a = Test::getInstance();
$b = Test::getInstance();
Nathan Nobbe wrote:
On Jan 30, 2008 10:46 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you? http://stut.net/
you realize you are
On Jan 30, 2008 10:46 AM, Stut [EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why would you? http://stut.net/
you realize you are instantiating an class in the code you posted, right?
from
Nathan Nobbe wrote:
It's fairly likely that I'd actually just use a static method here,
both your and my code use static methods. it sounds to me like you are
using the term 'static method' to mean a static method that has a variable
with a reference to an instance of the class that it is
Stut wrote:
Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.
then what exactly did you mean by this?
Actually no, I mean I would *just*
Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.
then what exactly did you mean by this?
Actually no, I mean I would *just* use a static
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.
then what exactly did you mean by this?
Actually no, I mean I would *just* use a static method. If there is no
reason to instantiate an object, why
Stut wrote:
Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.
then what exactly did you mean by this?
Actually no, I mean I would *just*
On Jan 30, 2008 11:21 AM, Stut [EMAIL PROTECTED] wrote:
Calling a static method
does not create an instance of the class.
there you go again; calling a static method does create an instance of
the class if you call new inside of it :P
-nathan
Jim Lucas wrote:
Stut wrote:
Nathan Nobbe wrote:
On Jan 30, 2008 10:53 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Nathan Nobbe wrote:
I never said I wasn't creating
an instance in the example I posted.
then what exactly did you mean by this?
Actually no, I mean
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED] wrote:
I would *just* use a static method
*just* *just* *just* *just* *just* *just* *just* *just* *just*
No instance. None. Grrr.
here is a mod of the code you posted w/ a var_dump() of the
local variable $o;
?php
class Test {
public
Nathan Nobbe wrote:
On Jan 30, 2008 11:21 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Calling a static method
does not create an instance of the class.
there you go again; calling a static method does create an instance of
the class if you call new inside of it :P
Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
I would *just* use a static method
*just* *just* *just* *just* *just* *just* *just* *just* *just*
No instance. None. Grrr.
here is a mod of the code you posted w/ a var_dump()
On Jan 30, 2008 11:58 AM, Stut [EMAIL PROTECTED] wrote:
Ok, I'm going to have to assume you really are as stupid as you seem. If
I need to provide an example to demonstrate what I meant I will, but I
feel I made it quite clear that my comment regarding what *I* would do
did not in any way
Stut wrote:
Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
I would *just* use a static method
*just* *just* *just* *just* *just* *just* *just* *just* *just*
No instance. None. Grrr.
here is a mod of the code you posted w/
Nathan Nobbe wrote:
On Jan 30, 2008 11:58 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Ok, I'm going to have to assume you really are as stupid as you seem. If
I need to provide an example to demonstrate what I meant I will, but I
feel I made it quite clear that my
Indeed. Now, the place where you sleep... is it guarded?
well it is, but..
i probly misunderstood some implication in the directions of
my virtual fortress and therefore, probly not as well a i suspect ;)
-nathan
Jim Lucas wrote:
Stut wrote:
Nathan Nobbe wrote:
On Jan 30, 2008 11:31 AM, Stut [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
I would *just* use a static method
*just* *just* *just* *just* *just* *just* *just* *just* *just*
No instance. None. Grrr.
here is a mod of the
On Wed, January 30, 2008 9:53 am, Stut wrote:
The forcing it out of scope was the crux of my point. However, if
Jochem is right then it's kinda pointless with the current
implementation of the GC, but may become relevant in the new GC.
I dunno about the OOP instances getting GC'ed, but PHP
I dunno about the OOP instances getting GC'ed, but PHP *definitely*
reclaims memory from arrays and strings as they go out of scope,
usually.
Does anyone else find that funny? :)
It definitely does it ... usually ;)
--
Postgresql php tutorials
http://www.designmagick.com/
--
PHP General
I believe the constructor returns the object created, with no chance
in userland code of altering that fact, over-riding the return value,
or any other jiggery-pokery to that effect.
New causes the constructor to be called in the first place, and that's
about it.
The assignment to a variable is
On Wed, January 30, 2008 6:19 pm, Chris wrote:
I dunno about the OOP instances getting GC'ed, but PHP *definitely*
reclaims memory from arrays and strings as they go out of scope,
usually.
Does anyone else find that funny? :)
It definitely does it ... usually ;)
Ah well.
It definitely
Richard Lynch wrote:
On Wed, January 30, 2008 6:19 pm, Chris wrote:
I dunno about the OOP instances getting GC'ed, but PHP *definitely*
reclaims memory from arrays and strings as they go out of scope,
usually.
Does anyone else find that funny? :)
It definitely does it ... usually ;)
Ah
Richard Lynch schreef:
I believe the constructor returns the object created, with no chance
in userland code of altering that fact, over-riding the return value,
or any other jiggery-pokery to that effect.
New causes the constructor to be called in the first place, and that's
about it.
The
On Jan 30, 2008 4:53 PM, Jochem Maas [EMAIL PROTECTED] wrote:
Richard Lynch schreef:
I believe the constructor returns the object created, with no chance
in userland code of altering that fact, over-riding the return value,
or any other jiggery-pokery to that effect.
New causes the
On Jan 30, 2008 11:29 PM, Casey [EMAIL PROTECTED] wrote:
I don't think constructors return the object:
im starting to think this as well.
what for example happens when there is not __construct() method ?
class Test {
private $blah = '';
}
here $blah is part of a new instance, before
Nathan Nobbe schreef:
On Jan 29, 2008 3:02 PM, Stut [EMAIL PROTECTED] wrote:
Why? What exactly do you think you're saving by not putting the
instance in a variable? I can't think of one good reason to do this.
its an esthetic thing; and besides the simple factory method is an
easy
On Jan 29, 2008 3:26 PM, Jochem Maas [EMAIL PROTECTED] wrote:
Nathan Nobbe schreef:
On Jan 29, 2008 3:02 PM, Stut [EMAIL PROTECTED] wrote:
Why? What exactly do you think you're saving by not putting the
instance in a variable? I can't think of one good reason to do this.
its an
On Jan 29, 2008 1:53 PM, Christoph Boget [EMAIL PROTECTED] wrote:
Constructors return the object, correct? If so, how can I do this:
class Bob {
private $blah;
_construct( $blah ) {
$this-blah = $blah;
}
public getBlah() {
return $this-blah;
}
}
echo Bob( 'Hello!'
On Jan 29, 2008 1:53 PM, Christoph Boget [EMAIL PROTECTED] wrote:
Constructors return the object, correct?
Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.
Andrew
--
PHP General Mailing List (http://www.php.net/)
To
On Tue, 2008-01-29 at 14:17 -0500, Eric Butera wrote:
http://www.travisswicegood.com/index.php/2007/10/26/fluent_api_here_i_come
Looks like a repurpose of one of my posts:
http://fsiu.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=gen9Srv59Nme5_7092_1182404204
--Paul
All Email
Christoph Boget wrote:
Constructors return the object, correct? If so, how can I do this:
class Bob {
private $blah;
_construct( $blah ) {
$this-blah = $blah;
}
public getBlah() {
return $this-blah;
}
}
echo Bob( 'Hello!' )-getBlah();
When I try that, I get the message
Constructors return the object, correct? If so, how can I do this:
class Bob {
private $blah;
_construct( $blah ) {
$this-blah = $blah;
}
public getBlah() {
return $this-blah;
}
}
echo Bob( 'Hello!' )-getBlah();
When I try that, I get the message Undefined function Bob. I've
On Jan 29, 2008 2:27 PM, Andrew Ballard [EMAIL PROTECTED] wrote:
On Jan 29, 2008 1:53 PM, Christoph Boget [EMAIL PROTECTED]
wrote:
Constructors return the object, correct?
Actually, I don't think so. I believe constructors return void, while
the 'new' keyword returns a copy of the object.
On Jan 29, 2008 2:37 PM, Paul Scott [EMAIL PROTECTED] wrote:
Looks like a repurpose of one of my posts:
http://fsiu.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=gen9Srv59Nme5_7092_1182404204
actually, this is slightly different; here we are talking about being
able to immediately
On Jan 29, 2008 2:37 PM, Paul Scott [EMAIL PROTECTED] wrote:
Looks like a repurpose of one of my posts:
http://fsiu.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=gen9Srv59Nme5_7092_1182404204
actually, this is slightly different; here we are talking about being
able to immediately
Christoph Boget schreef:
Constructors return the object, correct? If so, how can I do this:
class Bob {
private $blah;
_construct( $blah ) {
$this-blah = $blah;
}
public getBlah() {
return $this-blah;
}
}
echo Bob( 'Hello!' )-getBlah();
When I try that, I get the message
On 29 Jan 2008, at 19:43, Christoph Boget [EMAIL PROTECTED] wrote:
On Jan 29, 2008 2:37 PM, Paul Scott [EMAIL PROTECTED] wrote:
Looks like a repurpose of one of my posts:
http://fsiu.uwc.ac.za/index.php?module=blogaction=viewsinglepostid=gen9Srv59Nme5_7092_1182404204
actually, this is
On Jan 29, 2008 3:02 PM, Stut [EMAIL PROTECTED] wrote:
Why? What exactly do you think you're saving by not putting the
instance in a variable? I can't think of one good reason to do this.
its an esthetic thing; and besides the simple factory method is an
easy workaround to achieve it.
as the
On 29 Jan 2008, at 20:08, Nathan Nobbe [EMAIL PROTECTED] wrote:
On Jan 29, 2008 3:02 PM, Stut [EMAIL PROTECTED] wrote:
Why? What exactly do you think you're saving by not putting the
instance in a variable? I can't think of one good reason to do this.
its an esthetic thing; and besides the
On Jan 29, 2008 7:27 PM, Stut [EMAIL PROTECTED] wrote:
Personally I'd use a static method in this instance.
thats what i recommended.
If you need to create
an instance of the class you can do so in the static method and that way it
will get destroyed when the function is done. Otherwise the
47 matches
Mail list logo