Re: [PHP] Class constants

2010-04-19 Thread David Harkness
t; constant and replicated its value in the other constants--a situation constants were designed to obviate. Gary, you'd probably be better off asking for the technical reason behind this limitation on a -devel list. :) -- David Harkness Senior Software Engineer High Gear Media, Inc.

Re: [PHP] Re: What's your game? (X-PHP)

2010-04-27 Thread David Harkness
Left 4 Dead 2, by far my favorite game on the PC, is my current fixation. I enjoy Battlefield 2: Bad Company but tend to get annoyed having to face opponents 5-10 x my level. You can find me as Captain Cujo on both games. On Sun, Apr 25, 2010 at 10:37 AM, Nathan Rixham wrote: > however, there is

Re: [PHP] create tree from arrays

2010-05-17 Thread David Harkness
Shahrzad, While your algorithm is correct it is very inefficient. The full array is scanned for every element in the array. If the array contains 1,000 elements, 1,000,000 comparisons will be performed and mktree_array() will be called 1,000 times. This is known as order n squared: O(n^2) and is a

Re: [PHP] create tree from arrays

2010-05-17 Thread David Harkness
On Mon, May 17, 2010 at 9:13 AM, Richard Quadling wrote: > OOI, can you take a look at my first response. Is this the sort of > thing you were talking about? > Essentially, yes. For the temporary array I would map nid => element instead of INDEX => nid. Your $Relationships array is basically the

Re: [PHP] is

2010-06-10 Thread David Harkness
On Thu, Jun 10, 2010 at 3:34 PM, Ahmed Mohsen wrote: > I know that i should use the full open tag in php but i want to > know if its good to use this tag instead of > According to some PHP 6 will remove support for short tags. They won't be disabled by default--the feature simply won't exist.

Re: [PHP] is

2010-06-10 Thread David Harkness
On Thu, Jun 10, 2010 at 4:49 PM, Daniel Brown wrote: > You'll still see short_open_tags, That's good to hear. Not that we're in any rush to jump into PHP6 given that we're only just now *close* to deploying 5.3. > but you'll no > longer have ASP-style tags or the little-known

Re: [PHP] is

2010-06-11 Thread David Harkness
On Fri, Jun 11, 2010 at 11:16 AM, Ashley Sheridan wrote: > For which can cause issues when outputting the XML declaration line unless > it's broken into two parts, which is messier than ' Can you give an example of how this breaks? I don't see any problems with ' ?> unless you are trying t

Re: [PHP] is

2010-06-11 Thread David Harkness
On Fri, Jun 11, 2010 at 2:51 PM, Ashley M. Kirchner wrote: > They had every single file starting with: > > > *PHP* files? I would have flagged that as the problem rather than disabling short tags. David

Re: [PHP] Static Class Member References

2010-07-14 Thread David Harkness
Ah, so assigning a reference to a variable already holding a reference changes that variable's reference only in the same way that unsetting a reference doesn't unset the other variables referencing the same thing, yes? $a = 5; $b = &$a; print $a; > 5 unset($b); // does not affect $a print $a; >

Re: [PHP] Does class length slow down performance

2010-07-22 Thread David Harkness
On Thu, Jul 22, 2010 at 2:40 AM, Ashley Sheridan wrote: > The larger a script or class is, the more memory this uses per instance. > This is not quite true. When the script is loaded, it requires a fixed amount of memory to parse it. The larger it is, the more memory it requires. Next, the script

Re: [PHP] Re: Does class length slow down performance

2010-07-26 Thread David Harkness
On Sat, Jul 24, 2010 at 5:57 AM, Nathan Rixham wrote: > If you think about it, each class, function, method, line of code all gets > interpreted in to opcodes and executed - so, no matter how you split it up, > it's still going to produce roughly equivalent opcodes. > An exception to this is whe

[PHP] PHP 5.3 as a requirement for a library?

2010-07-29 Thread David Harkness
I'm working on the Hamcrest matching library and have been considering the switch to using namespaces (\Hamcrest\Type\IsInteger) instead of class-names-as-namespaces (Hamcrest_Type_IsInteger). Coming from the Java world I'm used to being forced to deploy my applications on versions one or two behin

Re: [PHP] logical AND assignments

2010-09-08 Thread David Harkness
The reason for "and" to have such a low precedence is so you can use it to perform conditional processing. You can probably achieve every effect using "&&", but you'd need more parentheses. More typically you would use "or" in this fashion: defined('DS') or define('DS', DIRECTORY_SEPARATOR);

Re: [PHP] logical AND assignments

2010-09-08 Thread David Harkness
On Wed, Sep 8, 2010 at 9:55 AM, Peter Lind wrote: > || and && would work exactly like 'or' and 'and' in the above. ==, !=, > === and !=== have higher precedence than || or && > Ah, you're correct. The only operators between &&/|| and and/or and the ternary ?: and assignment operators. Thus the n

Re: [PHP] re: logical AND assignments

2010-09-10 Thread David Harkness
On Fri, Sep 10, 2010 at 8:22 AM, Robert E. Glaser wrote: > It's hard to wrap my mind around the concept that the assignment > operator itself has an operator precedence. Which means that one could > write expressions without any assignment at all, and be syntactically > correct. > You do this al

Re: [PHP] Zend framework

2010-09-10 Thread David Harkness
We use part of Zend MVC (the dispatcher, controllers, and view scripts) here and a lot of the other facilities such as the autoloader, config, etc. and are very happy so far. As long as you design your application with an eye toward portability, you won't be tied to ZF. For example, put all of your

Re: [PHP] Re: Xpath arguments in variable

2010-09-15 Thread David Harkness
And let's not forget $v = $row->xpath("//membernumber[. = \"$MemberId\"]"); The \" inside the string turns into a double-quote and using " to delimit the string allows for variable substitution.

Re: [PHP] Re: Xpath arguments in variable

2010-09-16 Thread David Harkness
On Thu, Sep 16, 2010 at 1:20 AM, Pete Ford wrote: > On 15/09/10 18:00, David Harkness wrote: > >> $v = $row->xpath("//membernumber[. = \"$MemberId\"]"); >> > > Oooh, I hate using backslashes - they always seem so untidy... > I have a patholog

Re: [PHP] Re: Which PHP 5.3 documentation generators have you found?

2010-09-30 Thread David Harkness
While we don't use any 5.3 specific features such as namespaces yet, we set up our continuous integration system to use Doxygen. It runs significantly faster than phpDocumentor, though we put zero effort into tuning either system.

Re: [PHP] Re: Is it possible to create a global namespace alias?

2010-10-05 Thread David Harkness
On Tue, Oct 5, 2010 at 8:41 AM, Matt Palermo wrote: > I'm assuming there is no way to make a global alias. Can anyone > confirm/deny this? > I reread the documentation on namespaces, and from what I can tell this is no way to do it. Each file maintains its own active namespace *at compile time*

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread David Harkness
If you have total control over application A which contains the bridge code, the easiest is to change it to use a different global variable, $dbA. This must not be doable or you wouldn't have asked. If you have control over the bridge code, and it alone calls A and B, then you could swap the $db v

Re: [PHP] Casting from parent class to child

2010-10-06 Thread David Harkness
Casting does not change an object. You must copy the relevant value(s) from the object returned into a new DateTimePlus. Since DateTime's constructor takes only a string, and I assume it won't accept your format directly, you're better off converting the string into a Unix timestamp and creating a

Re: [PHP] What other languages do you use?

2010-10-08 Thread David Harkness
On Fri, Oct 8, 2010 at 10:30 AM, Nathan Rixham wrote: > As per the subject, not what other languages have you used, but what other > languages do you currently use? > At work: PHP and Java mostly with some Javascript and BASH scripting thrown in for good measure. We use PHP for the website and J

Re: [PHP] RegExp question: how to add a number?

2010-10-14 Thread David Harkness
On Thu, Oct 14, 2010 at 1:42 PM, Andre Polykanine wrote: > But (attention, here it is!) if the string starts with > something like "Re[4]:", it should replace it by "Re[5]:". > Regular expressions do not support any mathematical operations. Instead, you need to use preg_match() to extract the nu

Re: [PHP] simple class & constructor

2010-10-19 Thread David Harkness
Note that you still have a typo, but maybe it's only in your email messages: class simpleConstructer { function __construct() { echo "running the constructor"; } } $test = new simpleConstructor(); The class is misspelled; it should be simpleConstructor. As a

Re: [PHP] simple class & constructor

2010-10-19 Thread David Harkness
The "constructor" is the __construct() method, and it gets executed automatically when you instantiate the class into an object. The class defines the state (fields/properties) and behavior (methods/functions) that its objects will have. Instantiating the class is the fancy term for creating a new

Re: [PHP] Re: Possible foreach bug; seeking advice to isolate the problem

2010-10-20 Thread David Harkness
On Wed, Oct 20, 2010 at 5:00 AM, Tommy Pham wrote: > Shouldn't that be $row = null since unset will remove the last value, not > just removing the variable also, from the array whereas the $row = null > will > tell the reference pointer that it doesn't point to a value. > No, that would assign n

Re: [PHP] Re: Possible foreach bug; seeking advice to isolate the problem

2010-10-20 Thread David Harkness
On Wed, Oct 20, 2010 at 11:08 AM, Tommy Pham wrote: > hmm.. About 8-9 years ago I did a project where I used the reference > in a foreach loop as the OP. unset not only remove the variable but > also the value in the array. I tried several methods at that time and > ended up assigning null to

Re: [PHP] Re: Possible foreach bug; seeking advice to isolate the problem

2010-10-25 Thread David Harkness
On Sat, Oct 23, 2010 at 6:48 PM, Jonathan Sachs <081...@jhsachs.com> wrote: > Now that I understand it, I can see the same thing would happen if I > wrote the equivalent code in C, and probably in Java. > Neither C nor Java have references as PHP does, and references in C++ cannot be changed to p

Re: [PHP] Implementing optional methods in a concrete class, but calling them from an abstract class.

2010-11-01 Thread David Harkness
On Mon, Nov 1, 2010 at 10:42 AM, Andrew Ballard wrote: > Right up to here, it sounded more like an interface than an abstract base > class. > I think there's an interface in there *and* a basic (HTTP? RPC?) implementation that receives and dispatches the messages. I would split these responsibil

Re: [PHP] Help with variable variables not being set for a multi-dimensional array

2010-11-10 Thread David Harkness
On Tue, Nov 9, 2010 at 6:55 PM, Daevid Vincent wrote: > I've used variable variables before but for some reason I can't figure this > snippet out. Why doesn't $ini_file get set (or appended to). > AFAIK variable variables can only reference actual variables--not array subscripts or other non-var

Re: [PHP] DOMDocument/DOMElement problem

2010-11-17 Thread David Harkness
On Wed, Nov 17, 2010 at 10:27 AM, Peter Lind wrote: > Quick note, in case anyone has similar problems: make sure that the > data you feed into DOMDocument is UTF8 encoded > I can attest to this as well. I just fixed a bug in our sitemap-building code that was producing some items with empty titl

Re: [PHP] Procedural Autoloader?

2010-11-22 Thread David Harkness
On Mon, Nov 22, 2010 at 12:37 PM, Jason Pruim wrote: > The autoloader function that is in PHP 5+ works on classes... But I'm not > finding anything that would do the same thing on the procedural end. > I'll start by explaining how it typically works with classes. The Zend Framework is a popular w

Re: [PHP] Procedural Autoloader?

2010-11-22 Thread David Harkness
The simplest solution would be to move those functions into static methods of classes. Place one class in each file to organize your functions and use an autoloader to load the classes. You don't need to instantiate the class to use the autoloader--just reference it statically: // library/Math

Re: [PHP] Procedural Autoloader?

2010-11-22 Thread David Harkness
On Mon, Nov 22, 2010 at 3:05 PM, Richard Quadling wrote: > Would it be overboard to use a namespace? Aren't namespaces handled by > the autoloader? If not autoload(), how about spl_autoloading? > Autoloading is for determining the path and filename where a named item is defined. Namespaces only g

Re: [PHP] new keyword combined with other things...

2010-12-07 Thread David Harkness
On Tue, Dec 7, 2010 at 1:55 PM, Paul M Foster wrote: > Here is an example from their [CodeIgniter] user manual: > > $this->db->select('title')->from('mytable')->where('id', $id)->limit(10, > 20); > This is known as a "fluent interface" because it attempts to make your code read more naturally--i.

Re: [PHP] PHP4 to PHP5 migration with E_STRICT

2010-12-07 Thread David Harkness
In getCategoryTypes() you're assigning a reference to the return value of getContentTypes(), and PHP doesn't like that. You can return a reference to a variable from a function, but taking the reference of a *value* is meaningless since you can only create references to variables. Just remove the &

Re: [PHP] new keyword combined with other things...

2010-12-08 Thread David Harkness
On Wed, Dec 8, 2010 at 9:31 AM, Paul M Foster wrote: > I agree. My advice for SQL is always to learn SQL rather than use a > bunch of active record functionality. But I'm sure people think I'm just > a curmudgeonly old turd. ;-} > Yes, absolutely learn SQL so you understand what's happening under

Re: [PHP] how can one run python script in php

2010-12-08 Thread David Harkness
On Wed, Dec 8, 2010 at 2:50 PM, Moses wrote: > I am trying to run a python script in php using exec or system command, but > there is no answer. > If you post the code you have tried, we can point out any errors you're making and help you find the solution. David

Re: [PHP] ORM doctrine

2010-12-09 Thread David Harkness
On Wed, Dec 8, 2010 at 11:11 PM, Daevid Vincent wrote: > Avoid these ORM things like the plague! . . . Not to > mention all that fancy "ORM" doesn't come without a price. It costs in > terms > of speed, as well as training. > If you value CPU time over developer time, by all means avoid ORM fram

Re: [PHP] ORM doctrine

2010-12-10 Thread David Harkness
On Thu, Dec 9, 2010 at 7:41 PM, Daevid Vincent wrote: > I disagree. If you use a framework, then you're stuck with it. Bugs and all > (and trust me there are bugs and limitations you WILL run into). I have fixed bugs locally in third party libraries; I have submitted them for patching; I have r

Re: [PHP] Use PHP the way God intended...

2010-12-13 Thread David Harkness
On Mon, Dec 13, 2010 at 8:48 PM, Paul M Foster wrote: > Nah, if he'd read it backwards, you'd be able to hear MePHPistoPHPeles > say, "Rasmus is the Penguin". > > (Yes, you have to be dang old to get that obscure reference. ;-) > Pshaw, not *that* old! I get the reference, and I'm only . . . oh,

Re: [PHP] Use PHP the way God intended...

2010-12-14 Thread David Harkness
On Tue, Dec 14, 2010 at 8:43 AM, Paul M Foster wrote: > Er... that's Paul McCartney, not Paul Foster. Whew! > Paul McCartney's dead?? But the Beatles just released a ton of albums on iTunes! So sad...

Re: [PHP] How does one reply to messages on this list?

2010-12-16 Thread David Harkness
On Thu, Dec 16, 2010 at 8:09 AM, Daniel Molina Wegener wrote: > If your MUA (or email client) is smart enough, it should have at least > > "Reply", "Reply to Sender", "Reply to All" and "Reply to Mailing List". > To which my client adds "Reply to /dev/null", "Reply to Those Who Actually Care", a

Re: [PHP] String passed to object constructor turning into aninstance of that object?

2010-12-16 Thread David Harkness
It's acting as if Tag's constructor a) declares $name as a reference using &$name, and b) is assigning itself ($this) to $name for some (probably bad) reason. That's the only way I can see that $name inside SelectBoxOption's constructor could change from a string to an object. A peek at Tag's cons

Re: [PHP] String passed to object constructor turning into an instance of that object?

2010-12-16 Thread David Harkness
I've never used the old-style constructors, but perhaps the semantics of "parent::" changed and you need to instead use "$this->" as in $this->Tag("option", $name); That's a total guess. I don't have 5.2 handy to try it out, but both work in 5.3 using a simple example. Can you post the constr

[PHP] Does ReflectionMethod::setAccessible() do anything?

2010-12-16 Thread David Harkness
if the class under test has a private/protected constructor. I can solve the second problem with some further hacking, but there's nothing I can do about exposing private methods temporarily. setAccessible() seems perfectly designed to do what I need. Thanks, David [1] http://php.net/manual/

Re: [PHP] Problems w/ goto

2010-12-20 Thread David Harkness
On Fri, Dec 17, 2010 at 10:05 AM, la...@garfieldtech.com < la...@garfieldtech.com> wrote: > What PHP has implemented is "named break statements", as I understand it. > Not exactly. You can jump to arbitrary (labeled) lines within the same context (method/function), but you cannot enter loop const

Re: [PHP] Does ReflectionMethod::setAccessible() do anything?

2010-12-20 Thread David Harkness
ly want the method to be exposed for one call from the test method. David -- David Harkness Senior Software Engineer High Gear Media

Re: [PHP] Does ReflectionMethod::setAccessible() do anything?

2010-12-20 Thread David Harkness
ly want the method to be exposed for one call from the test method. David -- David Harkness Senior Software Engineer High Gear Media

Re: [PHP] Problems w/ goto

2010-12-20 Thread David Harkness
On Mon, Dec 20, 2010 at 7:45 PM, David Hutto wrote: > Is the problem with using the goto convolutedness(as I've seen other > senior programmers in other languages when explaining, or 'showing > off'), or is their an actual functional problem with it? It works perfectly well and is a great solut

Re: [PHP] Is there a simple way to enforce a private method in a subclass?

2010-12-21 Thread David Harkness
On Tue, Dec 21, 2010 at 8:36 AM, Richard Quadling wrote: > If I have an abstract class of Task and I want all subclasses of Task > to have a private method _runTask, is there a way to enforce this? > I cannot think of a reason to force a class to have a specifically-named *private* method. Since

Re: [PHP] accessing magic parent set

2010-12-22 Thread David Harkness
On Wed, Dec 22, 2010 at 6:35 AM, Alexandru Patranescu wrote: > Is this the only way to access the magic __set from the parent class: > >parent::__set($columnName, $value); > Other than referencing the parent class by name which is worse, yes. > I would have liked to work this way: > >pa

Re: [PHP] Static content at runtime

2010-12-28 Thread David Harkness
The other option is to generate the page dynamically and cache it (we use Varnish) for the next users. This way you pay the cost to regenerate pages only for those someone views--and only once. This pays off well when you have high traffic. David

Re: [PHP] Re: Do you trim() usernames and passwords?

2010-12-28 Thread David Harkness
On Tue, Dec 28, 2010 at 3:28 PM, Paul M Foster wrote: > Users would be wise to follow a scheme like > this, rather than using their dog's name or somesuch as their passwords. Aww man, I've been using "somesuch" as the password for all my accounts and now you've ruined it! Luckily I use your dog'

Re: [PHP] Newbie Question

2011-01-05 Thread David Harkness
On Wed, Jan 5, 2011 at 8:20 AM, tedd wrote: > I teach using NetBeans, because it generally sucks less than Eclipse. > Eclipse is simply too complicated and NetBeans tries to be less, but it's > still too much. > Have you tried PHPStorm? I installed it but haven't had a chance to play with it yet

Re: [PHP] Unload/reload included class

2011-01-05 Thread David Harkness
On Tue, Jan 4, 2011 at 4:44 PM, Patrik Pomichal wrote: > Loading plugin is easy, when my app found new file in plugins dir, > include and register it. But if i change the plugin source i must restart > the app to reload it. If you don't mind the resource burn (memory) of loading a lot of code ov

Re: [PHP] Newbie Question

2011-01-05 Thread David Harkness
On Wed, Jan 5, 2011 at 10:35 AM, Daniel Brown wrote: > On Wed, Jan 5, 2011 at 11:32, David Harkness > wrote: > > I do have to say that NetBeans more than Eclipse will randomly become > > unusable for unknown reasons: disk and CPU activity spike, > code-completion > &

Re: [PHP] Newbie Question

2011-01-05 Thread David Harkness
On Wed, Jan 5, 2011 at 3:05 PM, tedd wrote: > I spent a couple of hours reviewing PHPStorm and it looks *very* promising! Thank you for sharing your thoughts on PHPStorm. My main performance gripe with NetBeans has lessened in the year I've been using it, so I'm less inclined to go up yet anoth

Re: [PHP] Global or include?

2011-01-05 Thread David Harkness
On Wed, Jan 5, 2011 at 3:27 PM, Nathan Nobbe wrote: > if($cachedConfig !== null) > { >// load file and store value(s) in $cachedConfig > } > "No config for you ... one year!" Sorry, couldn't resist. :p To expand on Nathan's excellent strategy, you could go one further and add functions

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

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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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: 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] 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] 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] 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] 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] 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] 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] 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-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 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] 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] 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] 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] 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] 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] 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

  1   2   >