Re: [PHP] Reusable Singleton pattern using PHP5

2006-04-24 Thread Simas Toleikis
> php6 will include static late binding Great. Love the other new features, especially namespaces. > - until then you have 2 choices, > create a hack (see below) or stick redundant code into each class you > want to be a singleton. The hack doesn't work (See below). Guess we are left with copy-p

[PHP] Reusable Singleton pattern using PHP5

2006-04-24 Thread Simas Toleikis
Hello, As the %subj% says.. can't get it to work with PHP5. I mean, you could do this kind of stuff with templates/generics on other languages and then make a class singleton by just inheriting from base Singleton class. No need to redefine GetInstance() (which usually contains the same redundant

Re: [PHP] Getting static member for a class which name is stored in a variable

2004-11-26 Thread Simas Toleikis
Jake Press wrote: Hi Francisco, Your not alone, a number of other users have enountered this bug. string get_class ( object obj ) Its not a bug... You are getting class name as a string for output purposes etc.. Doing something like "TestClass"::some_static is ofcourse illegal wih strings. -- PHP

Re: [PHP] Simple coding question

2004-11-19 Thread Simas Toleikis
Octavian Rasnita wrote: $var = $_GET['var'] || 'value'; How about: $var = isset($_GET['var']) ? $_GET['var'] : 'value'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Silly OOP question

2004-11-15 Thread Simas Toleikis
Semantics. Until any langiage compiles to pure 1s and 0s, it's all about bytecode. Even C compiles to assembler which is really just a low level bytecode. Just a note: C compiles to opcodes. opcodes are 1s and 0s directly interpreted by CPU. Same applies to assembler. (asm->opcodes). The true i

Re: [PHP] PHP5 syntax question

2004-11-04 Thread Simas Toleikis
Gerard Samuel wrote: I dont see it in the documentation, but I've seen samples of code using something to the effect of -> $foo->method1()->method2() It's called object dereferencing and its not implemented in PHP4. It is avalaible in PHP5. If method1() returns an instance of some object then the

Re: [PHP] Register Globals

2004-10-25 Thread Simas Toleikis
And this won't pose as a security risk to me? It will. You could emulate namespaces in php. Do something like this: function init_namespace() { // all your script code goes here } init_namespace(); // notice the call This way any globally registered post/get/cookie etc variables wont be access

Re: [PHP] include()ing into a variable

2004-10-14 Thread Simas Toleikis
ApexEleven wrote: I believe that include() returns true|false, so $a would equal true if the file is included and false if it is not. If you use *return* on global scope in include file that value will be returned to $a. -- test.php -- $test = "Hello"; return $test; - $a = include "test.php";

Re: [PHP] GD

2004-10-09 Thread Simas Toleikis
Gerben wrote: how can i find out in PHP which version of GD is installed. I tried checking for function-existence of imagecreatetruecolor and imagecopyresampled, but these functions exist in older GD versions, but aren't implemented. I want to know if I can use the functions imagecreatetruecolor(

Re: [PHP] Interrupting instantiation

2004-10-07 Thread Simas Toleikis
Chris Boget wrote: In PHP4, is there any way to interrupt instantiation of an object? class Test { function Test() { $this = NULL; // Object destroyed by php gc } } $hello = new Test; // $hello = NULL -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://