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 Nick Whiting
This will not work. As stated in the PHP documentation "Static closures cannot have any bound object " A static Closure has no context of "this" just as with any other static object. A workaround is to pass in the Closure as a parameter to achieve a similar result. class TestClass { public

Re: [PHP] Binding object instances to static closures

2013-05-31 Thread Nathaniel Higgins
I'm talking about PHP 5.4. `bindTo` is a Closure method in PHP 5.4, and allows you to set the `$this` variable inside of a Closure. However, apparently you can't use it on Closures created inside static methods. I knew that you could create another function which would return the Closure, however,

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 ()

[PHP] Re: mcrypt_create_iv - why so slow?

2013-05-31 Thread Matt Graham
From: Nathan Nobbe > Interesting, using MCRYPT_DEV_URANDOM instead of MCRYPT_DEV_RANDOM > seems practically instantaneous. Still [raises] the question though, > any idea what's holding up the show w/ MCRYPT_DEV_RANDOM? /dev/random is a high quality entropy source and requires more time to generate

[PHP] Binding object instances to static closures

2013-05-31 Thread Nathaniel Higgins
Is it possible to bind an instance to a static closure, or to create a non-static closure inside of a static class method? This is what I mean... bindTo($testInstance); call_user_func($bindedTestClosure); // should be true } } TestClass::testMethod()

Re: [PHP] Looking for a good working PDO and/or mysqli database class to get started with OOP

2013-05-31 Thread dealTek
On May 30, 2013, at 7:30 PM, tamouse mailing lists wrote: > Sounds like the OP is asking for a pre-built CRUD interface that > adapts to his tables and their relationships. It's a fair question, > just one I don't have an answer to. There must be some kind of ORM for > PHP? Thanks tamouse -

[PHP] json_encode strange behavior

2013-05-31 Thread Bruno Hass de Andrade
Hi. I'm encoding some data with json_encode to use with jquery. All working fine, postgres query, my jquery, etc. But when I cast json_encode in my array, the result is an json object ordered by the array index, in my case the id of my clients. This is right? Is the intended behavior? Anyway, I f

Re: [PHP] Has this always been the case?

2013-05-31 Thread Tamara Temple
Richard Quadling wrote: > Hi. > > Both > > class Oddity{ > public $var = 'a' . 'b'; > } > ?> > >From http://www.php.net/manual/en/language.oop5.properties.php: "This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be

Re: [PHP] limit access to php page

2013-05-31 Thread Tamara Temple
Camilo Sperberg wrote: > On 30 mei 2013, at 05:05, Paul M Foster wrote: > > > On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote: > > > >> On May 29, 2013, at 7:11 PM, Tim Dunphy wrote: > >> > >>> Hello list, > >>> > >>> I've created an authentication page (index.php) that logs in

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

2013-05-31 Thread Tamara Temple
Tedd Sperling wrote: > On May 29, 2013, at 5:53 PM, Ashley Sheridan > wrote: > > Sometimes when all you know is regex, everything looks like a nail... > > > > Thanks, > > Ash > > > > There are people who *know* regrex? Well, not *biblically*, but yeah, I do. -- PHP General Mailing List

Re: [PHP] Has this always been the case?

2013-05-31 Thread Stuart Dallas
On 31 May 2013, at 12:22, Richard Quadling wrote: > On 31 May 2013 12:17, shiplu wrote: > >> On Fri, May 31, 2013 at 5:12 PM, Stuart Dallas wrote: >>> That is not entirely correct. It must be a literal value. The expression >>> 'a'.'b' is a constant value. >>> I may be being overly picky here

Re: [PHP] Has this always been the case?

2013-05-31 Thread Stuart Dallas
On 31 May 2013, at 12:17, shiplu wrote: > On Fri, May 31, 2013 at 5:12 PM, Stuart Dallas wrote: >> That is not entirely correct. It must be a literal value. The expression >> 'a'.'b' is a constant value. >> I may be being overly picky here, but I think it's an important distinction. >> > > I

Re: [PHP] Has this always been the case?

2013-05-31 Thread shiplu
On Fri, May 31, 2013 at 5:12 PM, Stuart Dallas wrote: > That is not entirely correct. It must be a literal value. The expression > 'a'.'b' is a constant value. > I may be being overly picky here, but I think it's an important distinction. > I thought 'a'. 'b' is a constant expression and 'ab' is

Re: [PHP] Has this always been the case?

2013-05-31 Thread Stuart Dallas
On 31 May 2013, at 12:08, shiplu wrote: > The property initializer in PHP can not have any expression. It should be > constant value. That is not entirely correct. It must be a literal value. The expression 'a'.'b' is a constant value. I may be being overly picky here, but I think it's an imp

Re: [PHP] Has this always been the case?

2013-05-31 Thread shiplu
Yes, this has been always the case. The property initializer in PHP can not have any expression. It should be constant value. If you want to use expression here use the constructor. class MyClass{ protected $nonStaticField; static protected $staticField; public function __construct(){

Re: [PHP] Has this always been the case?

2013-05-31 Thread Stuart Dallas
On 31 May 2013, at 11:57, Richard Quadling wrote: > Hi. > > Both > > class Oddity{ > public $var = 'a' . 'b'; > } > ?> > > and > > class Oddity{ > const A_VAR = 'a' . 'b'; > } > ?> > > produce ... > > PHP Parse error: syntax error, unexpected '.', expecting ',' or ';' in - > on line 3 >