[PHP] mcrypt_create_iv - why so slow?

2013-05-31 Thread Nathan Nobbe
Hi folks, This code: ?php $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC), MCRYPT_DEV_RANDOM); var_dump($iv); Takes just over a minute to run on my laptop and roughly 45 seconds on a capable server, any idea why? time php test-iv.php string(32)

[PHP] Re: mcrypt_create_iv - why so slow?

2013-05-31 Thread Nathan Nobbe
Interesting, using MCRYPT_DEV_URANDOM instead of MCRYPT_DEV_RANDOM seems practically instantaneous. Another less elegant solution I've found is to simply str_pad to the length returned by mcrypt_get_iv_size. Still begs the question though, any idea what's holding up the show w/

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

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

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 12:08, shiplu shiplu@gmail.com 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

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

2013-05-31 Thread shiplu
On Fri, May 31, 2013 at 5:12 PM, Stuart Dallas stu...@3ft9.com 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

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

2013-05-31 Thread Stuart Dallas
On 31 May 2013, at 12:17, shiplu shiplu@gmail.com wrote: On Fri, May 31, 2013 at 5:12 PM, Stuart Dallas stu...@3ft9.com 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

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

2013-05-31 Thread Stuart Dallas
On 31 May 2013, at 12:22, Richard Quadling rquadl...@gmail.com wrote: On 31 May 2013 12:17, shiplu shiplu@gmail.com wrote: On Fri, May 31, 2013 at 5:12 PM, Stuart Dallas stu...@3ft9.com wrote: That is not entirely correct. It must be a literal value. The expression 'a'.'b' is a

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

2013-05-31 Thread Tamara Temple
Tedd Sperling tedd.sperl...@gmail.com wrote: On May 29, 2013, at 5:53 PM, Ashley Sheridan a...@ashleysheridan.co.uk 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

Re: [PHP] limit access to php page

2013-05-31 Thread Tamara Temple
Camilo Sperberg unrea...@gmail.com wrote: On 30 mei 2013, at 05:05, Paul M Foster pa...@quillandmouse.com wrote: On Wed, May 29, 2013 at 08:51:47PM -0400, Tedd Sperling wrote: On May 29, 2013, at 7:11 PM, Tim Dunphy bluethu...@gmail.com wrote: Hello list, I've created an

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

2013-05-31 Thread Tamara Temple
Richard Quadling rquadl...@gmail.com wrote: Hi. Both ?php 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

[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

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 tamouse.li...@gmail.com 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?

[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... ?php class TestClass { public static function testMethod() { $testInstance = new TestClass(); $testClosure =

[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

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 n...@nath.is 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 =

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,

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 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 nwhit...@xstudiosinc.comwrote: