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 code you posted w/ a var_dump() of the
local variable $o;

<?php
class Test {
    public static function doSomething() {
        $o = new Test();
        var_dump($o);
        $o->_doSomething();
    }

    protected function _doSomething() {
        // I'm assuming this method is fairly complex, and involves
        // more than just this method, otherwise there is no point
        // in creating an instance of the class, just use a static
        // method.
    }
}
Test::doSomething();
?>

[EMAIL PROTECTED] ~/ticketsDbCode $ php testCode.php
object(Test)#1 (0) {
}


clearly in the act of *just* using a static method, you *just*
created an instance of class Test ;)

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 relate to the code example I had provided above. The example I provided was fulfilling the OP's requirements.

This is what *I* would do...

<?php
class Test {
    public static function doSomething() {
        // I'm assuming this method is fairly complex, and involves
        // more than just this method, otherwise there is no point
        // in creating an instance of the class, just use a static
        // method.

        // ^^^^ See this comment here, this was taken from the
        // non-static method in the example I posted. This is what
        // I meant when I say "just use a static method".
    }
}
Test::doSomething();
?>

Look ma, no instance.

Now this is clear.

Glad to hear it.

But to point out in the code I quoted, you said that you were going to only use the static method, but you were calling the static method that created an instance of the Test class and then calling the non-static method from the instance of the Test class.

I thought the comment in that static method explained that I didn't see the point in creating the instance. I thought it was pretty clear, but clearly not.

Your previous example was not showing us what you were saying. To me it looked like you were confused about how you were calling/creating things.

I was never confused! ;)

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to