Re: Re: [NEWBIE GUIDE] For the benefit of new members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Lynch wrote:
Oh and by the way, whenever I'm creating the skeleton of a new class I
will usually insert the following code snippet into the functions to let
me know I have to come back and actually implement it later.

if ($class = __CLASS__) {
  trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is not finished.',
E_USER_WARNING);
} else {
  trigger_error(__FUNCTION__ . ' is not finished.', E_USER_WARNING);
}


Why the assignment to $class?

Is that supposed to be == or is it just allowing for static class/method
calls with no object instantiated?

The assignment was intentional... but the reason is that it's my generic trigger for any function / method. So that this can be used inside of incomplete functions as well as methods.


<?php

class test2 {
static function test3() {
if (__CLASS__) {
trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is not finished.', E_USER_WARNING);
} else {
trigger_error(__FUNCTION__ . ' is not finished.', E_USER_WARNING);
}
}
}


function test() {
if (__CLASS__) {
trigger_error(__CLASS__ . '::' . __FUNCTION__ . ' is not finished.', E_USER_WARNING);
} else {
trigger_error(__FUNCTION__ . ' is not finished.', E_USER_WARNING);
}
}


test();
$t2 = new test2();
$t2->test3();
test2::test3();

?>


And would not 'if (__CLASS__)' serve just as well?


Good point... no need to assign to the variable; __CLASS__ alone is more efficient.



-- Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux