Re: [PHP] PHPDoc way to describe the magic getter/setters [SOLVED]

2013-09-25 Thread David Harkness
On Wed, Sep 25, 2013 at 4:31 PM, Daevid Vincent wrote: > Then I randomly stumbled upon this PHPDoc @ method tag and my whole world > is brighter today than it has been for the past, oh let's say DECADE! Yes, @method and @property are very handy. Out of curiosity, since you're providing magic g

Re: [PHP] PHP Dependency Injector

2013-09-05 Thread David Harkness
On Thu, Sep 5, 2013 at 1:40 PM, Juan Sebastian Scatularo < sebastianscatul...@gmail.com> wrote: > Thanks Sorin, I will do that and I will have more care the next time. You can also check out Pimple [1] by the creator of the Symfony Framework. Peace, David [1] http://pimple.sensiolabs.org/

Re: [PHP] Static utility class?

2013-09-04 Thread David Harkness
On Wed, Sep 4, 2013 at 12:25 PM, Micky Hulse wrote: > I want to have a "utility" class that contain utility methods which should > have the option of being called multiple times on a page. > ... > To put it another way, is there any reason why I would not want to use the > above code? The main p

Re: [PHP] Re: PHP vs JAVA

2013-08-22 Thread David Harkness
On Thu, Aug 22, 2013 at 12:29 AM, Sebastian Krebs wrote: > Actually I think ".." is quite error-prone, because it is hard to > distinguish from "." or "_" on the _first_ glance, which makes the get > quickly through the code. [1] > I surround all operators except member access ("." and "->") with

Re: [PHP] Re: PHP vs JAVA

2013-08-21 Thread David Harkness
On Wed, Aug 21, 2013 at 7:56 PM, Curtis Maurand wrote: > Sebastian Krebs wrote: > Actually the problem is, that the dot "." is already in use. With > $foo.bar() you cannot tell, if you want to call the method "bar()" on the > > object "$foo", or if you want to concatenate the value of "$foo" to

Re: [PHP] Re: PHP5 OOP: Abstract classes, multiple inheritance and constructors

2013-06-21 Thread David Harkness
There's no way to bypass an overridden method using "parent", but you could add an abstract method that Child would implement. class Parent function __construct() { $this->foo = $this->getFoo(); } abstract function getFoo(); } David

Re: [PHP] What is the name of the pattern that will ...

2013-06-13 Thread David Harkness
Hi Richard, On Thu, Jun 13, 2013 at 10:16 AM, Richard Quadling wrote: > I'm building a class which needs to have certain methods called by the > subclass, but the subclass can extend but not obscure/override the > behaviour. > This is the Template Method pattern, though in this case you could us

Re: [PHP] Binding object instances to static closures

2013-05-31 Thread David Harkness
Thanks Nathaniel for the clarification about 5.4. We are still on 5.3 (and that only recently), so 5.4 is a ways off in our production systems. However, I'll read up on this since it may be useful in offline tools. On Fri, May 31, 2013 at 11:52 AM, Nick Whiting wrote: > TestClass::testMethod(func

Re: [PHP] Binding object instances to static closures

2013-05-31 Thread David Harkness
On Fri, May 31, 2013 at 10:54 AM, Nathaniel Higgins wrote: > Is it possible to bind an instance to a static closure, or to create a > non-static closure inside of a static class method? > PHP doesn't have a method to do this. In JavaScript you can use jQuery's var func = $.proxy(function ()

Re: [PHP] Re: need some regex help to strip out // comments but not http:// urls

2013-05-30 Thread David Harkness
On Wed, May 29, 2013 at 10:20 AM, Matijn Woudt wrote: > It is possible to write a whole parser as a single regex, being it terribly > long and complex. > While regular expressions are often used in the lexer--the part that scans the input stream and breaks it up into meaningful tokens like

Re: [PHP] need some regex help to strip out // comments but not http:// urls

2013-05-28 Thread David Harkness
Hi Daevid, On Tue, May 28, 2013 at 2:40 PM, Daevid Vincent wrote: > I appreciate the pointer, but our files, like many people, is a mixture of > HTML, PHP and JS in one file. This jsmin appears to only work on .js files > right? Also, everything else works great in our minifing method, just this

Re: [PHP] need some regex help to strip out // comments but not http:// urls

2013-05-28 Thread David Harkness
Hi Daevid, On Tue, May 28, 2013 at 2:17 PM, Daevid Vincent wrote: > I'm adding some minification to our cache.class.php . . . We have been using a native jsmin extension [1] which does a lot more without any trouble for over two years now. It's much faster than the equivalent PHP solution and

Re: [PHP] A Good OOP Tutorial/Read?

2013-05-17 Thread David Harkness
On Fri, May 17, 2013 at 7:04 AM, Tedd Sperling wrote: > To me there is no difference between an abstract class (without method > declarations) and an interface. > The key difference in OO languages that do not allow multiple inheritance is that you can always add an interface to an existing class

Re: [PHP] Re: Is BBCode Installed

2013-04-11 Thread David Harkness
Hi Stephen, I just tried installing the PECL extension, but it failed to build on PHP 5.4.6-1ubuntu1.2. I see Xdebug in the phpinfo output, and I assume other PECL extensions will show up there once installed. Good luck! David

Re: [PHP] Mystery foreach error

2013-03-13 Thread David Harkness
On Wed, Mar 13, 2013 at 5:10 PM, Sebastian Krebs wrote: > Because 'null' is the representation of "nothing" array_key_exists() and > isset() can be treated as semantically equivalent. As I said, these functions return different results for null values. It won't matter for Angela since she isn't

Re: [PHP] Mystery foreach error

2013-03-13 Thread David Harkness
On Wed, Mar 13, 2013 at 4:44 PM, Angela Barone wrote: > I ran across if(array_key_exists) and it seems to work. How does that > differ from if(isset($states[$state]))? Hi Angela, isset() will return false for an array key 'foo' mapped to a null value whereas array_key_exists() will return true

Re: [PHP] Does Scope-Resolution Operator Always Follow 'parent'?

2013-03-11 Thread David Harkness
Hi Eric, On Sun, Mar 10, 2013 at 8:21 PM, Eric James Michael Ritz < lobbyjo...@gmail.com> wrote: > I have a question about the `parent` keyword: is there any valid > situation where it can appear without the `::` operator following? > I wouldn't have thought it possible, but I just found one cas

Re: [PHP] Late static binding behaves differently in PHP 5.3 and PHP 5.4

2013-01-24 Thread David Harkness
Hi Keven, First, I don't see any late static binding being used here. LSB only applies when you access a static member using the static keyword within a class method. This code uses static properties but accesses them directly without going through class methods. Here's an example of LSB: cla

Re: [PHP] Static constructor support

2012-09-27 Thread David Harkness
On Wed, Sep 26, 2012 at 2:29 PM, Yves Goergen wrote: > How do other languages than C# call that? :-) > Java has "static initializers" which work the same way: they are executed when the class is first loaded and before any code can make use of the class. David

Re: [PHP] include selectively or globally?

2012-08-28 Thread David Harkness
On Tue, Aug 28, 2012 at 12:11 PM, Matijn Woudt wrote: > On Tue, Aug 28, 2012 at 6:55 PM, David Harkness > wrote: > > On Tue, Aug 28, 2012 at 4:39 AM, Matijn Woudt wrote: > >> > >> First of all, I believe [A] PHP is smart enough to not generate bytecode > >

Re: [PHP] include selectively or globally?

2012-08-28 Thread David Harkness
On Tue, Aug 28, 2012 at 4:39 AM, Matijn Woudt wrote: > First of all, I believe [A] PHP is smart enough to not generate bytecode > for functions that are not used in the current file. Think about the > fact that you can write a function with errors, which will run fine > until you call the functio

Re: [PHP] Two ways to obtain an object property

2012-08-15 Thread David Harkness
On Wed, Aug 15, 2012 at 1:28 AM, phplist wrote: > I can have a User object method "getSubscriberStatus()" which sets > $this->isASubscriber. But to use this I would have to run the method just > before the if statement. > > Or I could have a method "isASubscriber()" which returns the result, > me

Re: [PHP] PHP session variables

2012-08-08 Thread David Harkness
On Wed, Aug 8, 2012 at 8:24 AM, Ansry User 01 wrote: > I am setting the _SESSION variables in one of my file, but whenever I > leave the php page session variables are not accessible. As always, post some code demonstrating what you're doing. Help us help you! :) David

Re: [PHP] Re: Regex

2012-07-27 Thread David Harkness
On Fri, Jul 27, 2012 at 11:43 AM, Al wrote: > "%[\w\d,.]%" > "\w" will match digits so "\d" isn't necessary, but it will also match underscores which isn't desired. David

Re: [PHP] Regex

2012-07-27 Thread David Harkness
On Fri, Jul 27, 2012 at 10:16 AM, Ashley Sheridan wrote: > "Simon Dániel" wrote: > > >#[0-9a-zA-Z,\.]# > > You should escape out that period as it will match any character otherwise > The dot only matches a period inside a character class [...]. David

Re: [PHP] magic getter

2012-07-19 Thread David Harkness
If you want to block setting of public properties on your class, implement the magic setter. class Foo { private $data = array(); function __get($name) { return $this->data[$name]; } function __set($name, $value) { if ($name != 'foo') {

Re: [PHP] Strange foreach reference issue

2012-01-09 Thread David Harkness
On Sat, Jan 7, 2012 at 5:01 PM, Tim Behrendsen wrote: > The first loop is leaving a reference to the final element. But then the > second foreach is doing a straight assignment to the $row variable, but > $row is a reference to the final element. So the foreach is assigning its > iterated value t

Re: [PHP] call_user_func_array and bind_result

2011-12-16 Thread David Harkness
Each *value* in the array must be a reference to an existing variable--they cannot be null or direct values. I didn't try this with bind_param(), but I create a function that takes reference arguments and got it to work with call_user_func_array(): function foo(&$x, &$y) { $x *= 2; $y *= 3; }

Re: [PHP] Preferred Syntax

2011-12-14 Thread David Harkness
On Wed, Dec 14, 2011 at 4:59 AM, Rick Dwyer wrote: > Can someone tell me which of the following is preferred and why? > > echo " href='/mypage.php/$page_id'>$**page_name"; > > echo " href='/mypage.php/".$page_id."**'>".$page_name.""; > On Wed, Dec 14, 2011 at 9:09 AM, Peter Ford wrote: > Hor

Re: [PHP] RE: php-general Digest 9 Dec 2011 20:09:28 -0000 Issue 7604

2011-12-12 Thread David Harkness
On Mon, Dec 12, 2011 at 1:06 PM, David Savage wrote: > Would "ksort($sortarr,SORT_STRING)" on a 1 dimensional array with a key > comprised of > a person's name, > "-", and > time stamp > I..E. (key: david savage-2011-12-12 14:43:00) > actually delete duplicate keys from the array, if there were

Re: [PHP] Extending an instantiated class

2011-10-16 Thread David Harkness
On Sat, Oct 15, 2011 at 7:01 AM, Alain Williams wrote: > I have an application where a Screen (web page) may contain several Forms. > The Forms > will want to access properties, etc, from their Screen. So what I want is > to do > something like: > You're using an is-a relationship between Form a

Re: [PHP] Variable question

2011-10-01 Thread David Harkness
On Sat, Oct 1, 2011 at 10:59 AM, Ron Piggott wrote: > If $correct_answer has a value of 3 what is the correct syntax needed to > use echo to display the value of $trivia_answer_3? You can use variable variables [1] to access the variable by building its name in a string: $name = 'trivia_ans

Re: [PHP] PHP installations, usage, and popularity

2011-09-19 Thread David Harkness
On Mon, Sep 19, 2011 at 3:22 PM, Daniel Brown wrote: > On Mon, Sep 19, 2011 at 18:10, David Harkness > wrote: > > Gently remind them that the P in LAMP stands for PHP. > > It has become a presumption in that regard, yes, but the 'P' in > LAMP was actually f

Re: [PHP] PHP installations, usage, and popularity

2011-09-19 Thread David Harkness
Gently remind them that the P in LAMP stands for PHP. There's a big reason most every web developer can tell you what each letter in LAMP stands for: heavy market penetration. Peace, David

Re: [PHP] Querying a database for 50 users' information: 50 queries or a WHERE array?

2011-09-13 Thread David Harkness
On Tue, Sep 13, 2011 at 7:29 AM, Ashley Sheridan wrote: > SELECT * FROM table WHERE userID IN (1,2,3,4,5,etc) > +1. And this is a great place to use implode(): $sql = 'select ... where userID in (' . implode(',', $ids) . ')'; David

Re: [PHP] Code should be selv-maintaining!

2011-08-30 Thread David Harkness
I don't always use braces, but when I do I use Compact Control Readability style. Stay coding, my friends.

Re: [PHP] Using function prototypes in code

2011-08-10 Thread David Harkness
On Tue, Aug 9, 2011 at 6:10 PM, Frank Thynne wrote: > function integer int_func(string $s) { > // does something like, say, converting "five" to 5 > } > As Stuart pointed out, type-hinting currently only works for classes and arrays. Scalar type-hinting is planned for the future, but for now yo

Re: [PHP] Best editor?

2011-08-03 Thread David Harkness
On Wed, Aug 3, 2011 at 9:36 AM, Tamara Temple wrote: > Not to hijack the thread, but I really, *really* hope you are not > suggesting that someone do live edits on a production server I would never consider tinkering on test pages while learning PHP a "production" server. :)

Re: [PHP] static variables inside static methods

2011-07-06 Thread David Harkness
2011/7/6 Дмитрий Степанов > PHP documentation of static keywords does not unambiguously explain > behavior > of "static" variables inside methods in example #1. I believe that in > example #1 the exactly same instance of function (method) is used > irregarding of how you call it (X::test() or Y::

Re: [PHP] asynchronous launch of a script

2011-06-28 Thread David Harkness
On Tue, Jun 28, 2011 at 1:02 PM, Stuart Dallas wrote: > While this will work, I would caution against doing this, especially when > using Apache as the web server. . . . > > Forking an HTTP request handler can lead to some very unwelcome > side-effects. I'd urge you not to do this. It may appear

Re: [PHP] asynchronous launch of a script

2011-06-28 Thread David Harkness
On Sun, Jun 26, 2011 at 7:42 PM, Tamara Temple wrote: > How do I launch a php script from another running php script > asynchronously? > You can perform the long-running job in the same process that handles the request by sending appropriate headers. We use this to run reports that take ten minut

Re: [PHP] Import symbol table into function' scope.

2011-06-15 Thread David Harkness
2011/6/15 Дмитрий Степанов > So I wonder if there is any way to import scope (symbol table) into the > method DBReader::readSomething()? > Since you're using call_user_func_array() to call your internal methods already (just to expose protected methods publicly?), you could add $DB as a paramete

Re: [PHP] Uncatchable errors

2011-06-13 Thread David Harkness
On Mon, Jun 13, 2011 at 12:52 PM, Paul M Foster wrote: > > There's certain class of errors which happen before any error-handler > (set_error_handler) can catch them, like parse errors and such. Is there > a way to have these generate the same type of response as the errors > handled by set_error_

Re: [PHP] Class not used as an object (Scope Resolution Operator)

2011-06-09 Thread David Harkness
All of the above with a clarification: they are instance methods which you are calling statically. The object is not instantiated in this case. PHP allows this but will issue an E_STRICT warning. To remove the warning just add "static" before each of them, assuming they are only ever called statica

Re: [PHP] phpsadness

2011-06-03 Thread David Harkness
The original PHP Sadness page didn't actually make me sad. This thread, however, *is*. Can we all agree that we have different opinions on what makes an appropriate joke and move on? Here's to less sadness in the world . . . David

Re: [PHP] phpsadness

2011-05-27 Thread David Harkness
On Fri, May 27, 2011 at 12:52 PM, Daevid Vincent wrote: > A friend sent me this URL today. While amusing, he's got many valid points > and I certainly share in his frustration. > > http://www.phpsadness.com > Some points are valid, but many others show a lack of understanding of PHP and OOP in g

Re: [PHP] strcmp()?

2011-05-24 Thread David Harkness
On Tue, May 24, 2011 at 12:48 AM, Vitalii Demianets wrote: > So. to write compatible scripts one should check "< 0", not "== -1". > Which matches the documentation: Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal. David

Re: [PHP] best practise accessing object's attributes from objects itself

2011-05-23 Thread David Harkness
On Mon, May 23, 2011 at 6:29 AM, Simon Hilz wrote: > i was wondering if there is any best practise known how one should access > the attributes of an object from the object itself. > For most properties I use $this->property within the object because nine times out of ten no work ever needs to b

Re: [PHP] A Review Request

2011-05-20 Thread David Harkness
On Fri, May 20, 2011 at 12:28 PM, Alex Nikitin wrote: > Also you left out a database, your basement/foundation . . . I liken the database to the sewer: it's where all the crap goes. :D Happy Friday! David

Re: [PHP] PHP Rounding Question

2011-05-20 Thread David Harkness
On Fri, May 20, 2011 at 10:40 AM, Rick Dwyer wrote: > How do I coerce the result to always round up to the nearest increment 1/4? > $x = ceil($x * 4) / 4; David

Re: [PHP] [SPAM] Re: Explode Question

2011-05-18 Thread David Harkness
On Wed, May 18, 2011 at 4:30 PM, wrote: > If you say I hijacked a spam thread , then shame on me. It will not happen > again. > Do you have ANY IDEA how HARD I work to hand-craft my spam emails? Please do not HIJACK them with your work-related, information-seeking drivel! Thank you. David P.S.

Re: Re: [PHP] A Review Request

2011-05-18 Thread David Harkness
On Wed, May 18, 2011 at 2:38 PM, Peter Lind wrote: > As is probably clear by now, in my opinion it would be much better to > go the motions of the script a bit at a time, with comments of *why* > things are done (not *what* is done) - and why you really should spend > a bit more time learning abo

Re: [PHP] A Review Request

2011-05-18 Thread David Harkness
On Wed, May 18, 2011 at 2:22 PM, Peter Lind wrote: > You make my point for me but for some reason don't want to follow the > logical conclusion of it. Why? > > > This is just one way to give-back. > > Suggesting people that they copypaste your code is a very bad way of > giving back. Suggesting t

Re: [PHP] Bitwise AND for 31-st bit

2011-05-17 Thread David Harkness
It appears that PHP is truncating the constant 0x8000 to be within MIN_INT and MAX_INT instead of as a bit field, but when shifting 1 << 31 it doesn't do apply any constraints. That's pretty typical of bit-manipulation: it will merrily slide 1 bits off either end. This explains why & produces 0

Re: [PHP] Error recovery - fatal errors

2011-05-16 Thread David Harkness
You can register a shutdown function that gets called even in the case of a fatal error. We use something like this: public function init() { register_shutdown_function(array('Bootstrap', 'fatalErrorCatcher')); ... } public function fatalErrorCatcher() { $error

Re: [PHP] Functions/methods aliases in PHp 5.2

2011-05-16 Thread David Harkness
On Sun, May 15, 2011 at 3:15 PM, Richard Quadling wrote: > Personally, I would recommend using 1 naming convention and sticking with > it. > I wholeheartedly agree. Multiple method names is not flexibility--it's confusion and an open invitation for bugs. Plus, even with two styles you'll never sa

Re: [PHP] Odd array_push issue

2011-05-11 Thread David Harkness
On Wed, May 11, 2011 at 1:50 PM, Peter Lind wrote: > I'd say there's a problem in your code. Check where you might be using > references, chances are you're using one somewhere and not unsetting > it afterwards. > Also make sure that the code that receives the final array isn't modifying the obj

Re: [PHP] Odd array_push issue

2011-05-11 Thread David Harkness
On Wed, May 11, 2011 at 1:23 PM, Richard S. Crawford wrote: > If I execute the following code: > > array_push(objectarray, A); > array_push(objectarray, B); > > ...I expect the contents of $objectarray to be: > > [0] = A > [1] = B > > Instead, the last object pushed onto the array is repeated thro

Re: [PHP] Short tag: why is it bad practice?

2011-05-11 Thread David Harkness
On Wed, May 11, 2011 at 11:55 AM, Daevid Vincent wrote: > is generally NOT what the short tags controversy are about. > > It's the use of vs. > This is the same thing my colleague told me when I first joined and began learning PHP and is the reason we use stupid reason), the issue is that

[PHP] APC: Warming the bytecode cache with preload_path

2011-04-13 Thread David Harkness
Greetings, APC has an INI setting named apc.preload_path which I assume causes all PHP files within that path to be compiled and cached by APC as it is initialized. The documentation is nonexistent, but in this thread Rasmus corroborates my assumption (well, he doesn't invalidate it in any case):

Re: [PHP] Class Constants

2011-04-13 Thread David Harkness
On Wed, Apr 13, 2011 at 11:04 AM, Floyd Resler wrote: > That didn't quite work. Here's what I did: > $const=$argv[1]; > $value=email::$const; > Instead try this: $const = $argv[1]; $reflector = new ReflectionClass('email'); $value = $reflector->getConstant($const); David

Re: [PHP] a shortcut to set variable

2011-04-12 Thread David Harkness
On Tue, Apr 12, 2011 at 6:34 AM, Richard Quadling wrote: > Without running the code, can you say what the output will be in the 3 > examples? > Yes, but I would still rewrite that code. ;) I typically reserve the ternary operator to return a value or assign a variable. Given that it is used less

Re: [PHP] Ranges for case statement and a WTF moment.

2011-04-07 Thread David Harkness
On Thu, Apr 7, 2011 at 2:16 AM, Richard Quadling wrote: > And all this is shown when you ... > > php -r "print_r(array_map(function(&$token){if(is_array($token)){$token[0] > = token_name($token[0]);} return $token;},token_get_all(' 10...19;')));" > Woah, that's a very nifty trick! I like PHP more

Re: [PHP] Ranges for case statement and a WTF moment.

2011-04-06 Thread David Harkness
On Tue, Apr 5, 2011 at 8:28 AM, Richard Quadling wrote: > php -r "var_dump(10...19);" > > Interesting output ... > > string(6) "100.19" > > And that took me a little while to work out. > > It's all to do with PHP's type juggling. > > 10...19 > > What I'm not sure is why the middle empty string is

Re: [PHP] help with _get error

2011-03-23 Thread David Harkness
On Wed, Mar 23, 2011 at 10:46 AM, Jack wrote: > I'm having a problem with this line of code which worked fine for years: > > $l_url2 = ".".$_GET[SERVER_NAME]; > Place quotes around the key. $l_url2 = ".".$_GET['SERVER_NAME']; Normally PHP treats SERVER_NAME as the name of a constant. There

Re: [PHP] echo?

2011-03-22 Thread David Harkness
Are you sure? $ php -a php > for ($i = 0; $i < 10; $i++) { echo $i . ' '; } 0 1 2 3 4 5 6 7 8 9 David

Re: [PHP] Possible to pinpoint peak memory usage?

2011-03-11 Thread David Harkness
On Fri, Mar 11, 2011 at 11:35 AM, Daniel Hong wrote: > Is it possible to pinpoint the location where the most memory was used? Take a look at XHProf. [1] It will track memory and time of all function calls. Paul Reinheimer created a GUI [2] to make dealing with the data easier. Peace, David [

Re: [PHP] Re: Simplest way of enforcing an array of instances of a specific class but treating the whole thing as an array.

2011-02-24 Thread David Harkness
If each array will contain a single type of object, but you need many of these arrays, each containing a different type of object, I recommend creating a generic "instances-of-class" array using ArrayObject. You can enforce the type in append(), offsetSet(), and exchangeArray() and then check the c

Re: [PHP] Jquery

2011-02-15 Thread David Harkness
I see firebug-lite-debug.js but not jquery.js. Does firebug include jquery? David

Re: [PHP] Howdy (new in here)

2011-02-15 Thread David Harkness
On Tue, Feb 15, 2011 at 1:08 PM, Steve Staples wrote: > My personal bracing style is the Allman Style. > I use K&R. I started with it just as shown but as monitors increased in size I stopped cuddling the else so it's now on its own line, aligning the if, elseif, and else nicely. One of the deve

Re: [PHP] Howdy (new in here)

2011-02-15 Thread David Harkness
Welcome to the list, Brian. I'm fairly new to PHP and the list myself, and I've found it to be a great resource. Another is stackoverflow.com, especially for "How do I do X?" type questions. I often find someone else has already provided an answer. On Tue, Feb 15, 2011 at 8:51 AM, tedd wrote: >

Re: [PHP] Paging and permissions

2011-02-08 Thread David Harkness
On Tue, Feb 8, 2011 at 4:36 AM, Arno Kuhl wrote: > But it might be an option if done once at the start of each > search or list request, and then use that temporary modified result set for > subsequent requests on the same set. Instead of serializing the articles, you only need their IDs. Using

Re: [PHP] override built-in mail()

2011-02-04 Thread David Harkness
On Fri, Feb 4, 2011 at 12:42 PM, Hansen, Mike wrote: > I would opt for using my_mail and not overriding a built-in function. It > seems to me that it would just cause confusion for the next developer who > takes care of your code. You know, that psychopathic programmer that knows > your address.

Re: [PHP] Detecting Multi-Scope Variables

2011-02-01 Thread David Harkness
I think you can use reflection [1] to block the hooks from using & in their parameter lists. This way the clients must use & to pass a reference. This is definitely possible for function/method callbacks [2], but I'm not sure about 5.3 closures [3]. David [1] http://www.php.net/manual/en/reflecti

Re: [PHP] "public static" or "static public"?

2011-01-31 Thread David Harkness
On Mon, Jan 31, 2011 at 3:51 AM, Richard Quadling wrote: > I've just done a quick scan of all my methods ... > I just did the same scan on my code, and the clear majority was private abstract final function YMMV David

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread David Harkness
On Fri, Jan 28, 2011 at 11:03 AM, Marc Guay wrote: > If COUNTing is the heavy part, why not create a 'users_logged_in' > field somewhere and increment it when someone logs in and decrement it > when someone logs out? Then your query is just a straight SELECT. If this is like most web sites, us

Re: [PHP] Counting Online users, but not using a Session Table in MySQL

2011-01-28 Thread David Harkness
If you're using memcached already you could store the number in it and update it only when a user logs in/out. If no one is logging in/out, the number isn't changing. If your site is so popular that hundreds of users are logging in every second you might want to change the logic so that the proces

Re: [PHP] "public static" or "static public"?

2011-01-28 Thread David Harkness
On Fri, Jan 28, 2011 at 10:35 AM, Mujtaba Arshad wrote: > Having learned java before even knowing what php was (yeah I'm a noob in > both) I prefer scope static function. I learned Java first, too, and also prefer the scope first. I place a scope on every method, so I'd rather the first word alw

Re: [PHP] Re: Cross-platform IDE

2011-01-26 Thread David Harkness
FWIW while I prefer Eclipse overall as an IDE, I found the PHP support in NetBeans to be superior. It's been a year since I used Eclipse for PHP. Maybe the PHP plugins for Eclipse have improved enough. NetBeans supports GIT and Mercurial as well. David

Re: [PHP] preg_replace question

2011-01-24 Thread David Harkness
Without seeing the code that creates the arrays, it's tough to see the problem. It looks like the first replacement is catching "Beagle Welpen" entirely since the closing tag gets placed after "Welpen". Then the second replacement does just "Welpen". Also, you should have quotes around "link" whe

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-21 Thread David Harkness
On Fri, Jan 21, 2011 at 4:44 AM, Dotan Cohen wrote: > Then I would have to check what values are available when inserting, > and possibly normalise every so often. I'll think about that, and when > I have enough data in the database I'll set up a test system to play > with the possibility. > Yes

Re: [PHP] possible namespace bug?

2011-01-20 Thread David Harkness
On Thu, Jan 20, 2011 at 4:26 PM, Tommy Pham wrote: > Anyway, I found the problem: \N in > > use org\puremvc\php\patterns\observer\Notifier; > AFAIK \n is only processed inside double-quoted strings and here-docs. The \N has no special meaning beyond a namespace separator and a capital N. My

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-20 Thread David Harkness
On Thu, Jan 20, 2011 at 12:21 PM, Dotan Cohen wrote: > I understood that. My concern is exactly with adding new nodes. There > is no incrementor (++i) in SQL, so knowingly coding a solution that > will require incrementing two fields in half the database rows seems > irresponsible. > It only req

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-20 Thread David Harkness
On Thu, Jan 20, 2011 at 7:00 AM, Richard Quadling wrote: > I'd recommend using a nested set approach for the tags > (http://dev.mysql.com/tech-resources/articles/hierarchical-data.html > gives a good explanation on the issues and methodology of nested > sets). > Thanks for the link. That article

Re: [PHP] Class and interface location

2011-01-20 Thread David Harkness
Larry, I suggested the docblock tag because it seemed you didn't want to mandate that plugins that extend other plugins be forced to include the interface in an actual PHP implements clause. Duplicating the implements clause doesn't cause any problems for PHP as you said, so that's one route. Adv

Re: [PHP] Organisational question: surely someone has implemented many Boolean values (tags) and a solution exist

2011-01-20 Thread David Harkness
I cannot agree more with the others about using a join table. While it's tempting to go with your first solution due to fear of performance issues, you can usually address performance issues with a technical solution. Addressing problems that arise from a constraining design choice is much more dif

Re: [PHP] Class and interface location

2011-01-19 Thread David Harkness
What about creating your own docblock tag such as @plugin-interface? While it still requires each plugin to explicitly define the interface(s) it implements, it won't be in the class declaration. This would be very easy to nab for a tree of files using grep, removing the need to do any static analy

Re: [PHP] Closure and $this

2011-01-13 Thread David Harkness
On Wed, Jan 12, 2011 at 10:57 PM, Larry Garfield wrote: > I believe this is the relevant RFC: > > http://wiki.php.net/rfc/closures/object-extension > That was a good bedtime read last night, Larry. I prefer method A which is nearly identical to Java's inner classes where $this would remain tied t

Re: [PHP] Array Symbol Suggestion

2011-01-13 Thread David Harkness
On Thu, Jan 13, 2011 at 10:07 AM, David Hutto wrote: > On Thu, Jan 13, 2011 at 12:59 PM, David Harkness > > I learned it early on as well, and I never really liked it. Instead of > > $iFish I would prefer a more descriptive name such as $fishCount. > > What info did yo

Re: [PHP] Array Symbol Suggestion

2011-01-13 Thread David Harkness
On Thu, Jan 13, 2011 at 2:23 AM, Richard Quadling wrote: > The Hungarian Notation [1] was what I was taught all those years ago > when I learnt standard C programming. I learned it early on as well, and I never really liked it. Instead of $iFish I would prefer a more descriptive name such as $fi

Re: [PHP] HTML errors

2011-01-12 Thread David Harkness
On Wed, Jan 12, 2011 at 6:04 AM, David McGlone wrote: > Prounouncing words for a deaf person is often times difficult. > That makes perfect sense. Think about it, > spelling isn't about remembering how to spell the word, but how to > prounounce > it. Not so fast! While this argument can be ma

Re: [PHP] Stripping carriage returns

2011-01-11 Thread David Harkness
On Tue, Jan 11, 2011 at 11:13 AM, Richard S. Crawford wrote: > $content = preg_replace("/[".chr(10)."|".chr(13)."]/","",$content) > This should be $content = preg_replace('/[\r\n]/','',$content) First, you can embed \r and \n directly in the regular expression as-is (not converted to chr(1

Re: [PHP] First PHP job

2011-01-11 Thread David Harkness
On Tue, Jan 11, 2011 at 9:55 AM, Robert Cummings wrote: > My horse now has a perforated stomach and colon. Can I send you the > veterinarian's bill? > Who knew they made carrot-flavored $needles? David

Re: [PHP] Command line PHP

2011-01-11 Thread David Harkness
On Tue, Jan 11, 2011 at 10:12 AM, tedd wrote: > My down time is playing XBOX Black Ops. It allows my mind to focus on > things that don't matter, much like a vacation, that's frees space > For me that's Left 4 Dead 2 as Captain Cujo. I think it's beneficial to cultivate skills in something that

Re: [PHP] First PHP job

2011-01-11 Thread David Harkness
On Tue, Jan 11, 2011 at 4:19 AM, Jay Blanchard wrote: > I am always looking for the $needle in the $haystack. > > Just sayin' > I often find it faster to hire a bunch of horses to eat the $haystack, leaving the $needle behind and easy to find. David

Re: [PHP] Command line PHP

2011-01-07 Thread David Harkness
On Fri, Jan 7, 2011 at 10:41 AM, la...@garfieldtech.com < la...@garfieldtech.com> wrote: > "Application" is perhaps a misnomer. I'm not looking at rewriting Emacs or > anything. Just some batch processing that would get run as: > > php myscript.php --config=foo.xml --setting-1=stuff For this I

Re: [PHP] Command line PHP

2011-01-07 Thread David Harkness
On Fri, Jan 7, 2011 at 10:31 AM, Joshua Kehn wrote: > My apologies. I just view PHP as a perfected web language, due to it's > templating nature, while using it for other things (scripts, utilities, > cron) is a misuse in my opinion. > Even if you are proficient in more "CLI-appropriate" languag

Re: [PHP] OO oriented PHP frameworks

2011-01-06 Thread David Harkness
On Thu, Jan 6, 2011 at 12:36 PM, Jerome Covington wrote: > I was specifically curious if there are frameworks which use the convention > of passing config objects to functions/methods in the same way that > contemporary JS libraries like jQuery do. We use Zend Framework along with its MVC frame

Re: [PHP] Memory_Limit adjustments

2011-01-06 Thread David Harkness
The memory limit only blocks PHP from allocating more than that amount of memory for a single process (i.e. client request). Given that you're barely scratching the surface of your 2GB of memory, if you don't expect too many 17MB file uploads to happen at the same time from different users, you sho

Re: [PHP] PHP Docs update

2011-01-06 Thread David Harkness
I filed a bug report for this, but I'll put it here as well in case it helps. When you zoom in to increase the text size, the right margin increases unnecessarily. This shrinks the width of the center content column which makes reading the documentation and code snippets difficult. The right margin

  1   2   >