On Wed, July 5, 2006 3:32 pm, KermodeBear wrote:
>>> i don't want to:
>>>- or use a::print
> $myFoo =& Singleton::getFoo();
What's wrong in this picture? :-)
As far as I can tell, the original poster shouldn't be using PHP,
since he wants the language to have some kind of implicit "$this"
-
>> hi all,
>> i wonder if there is a way of creating an instance of a class and
>> reach it direcly from any scope in PHP4. basically what i want is:
>> i don't want to:
>>- declare global $foo,
>>- use pre-defined $GLOBALS variable,
>>- or use a::print
>>
>> thanks.
> Static is your
On 7/1/06, sempsteen <[EMAIL PROTECTED]> wrote:
hi all,
i wonder if there is a way of creating an instance of a class and
reach it direcly from any scope in PHP4. basically what i want is:
class a
{
function print()
{
echo 'sth';
}
}
$a = new a();
and use this "a" instance from
On Sat, July 1, 2006 4:56 am, sempsteen wrote:
> i wonder if there is a way of creating an instance of a class and
> reach it direcly from any scope in PHP4. basically what i want is:
>
> class a
> {
>function print()
>{
> echo 'sth';
>}
> }
>
> $a = new a();
>
> and use this "a"
sempsteen wrote:
yes i'm calling a lot. actually i have a class that handles mysql
queries named "database".
what i want was call a database method from a method of another function.
class
function
...$database->execute_query(...
Always CC the list.
What's wrong with this being a glo
On 7/1/06, sempsteen <[EMAIL PROTECTED]> wrote:
hi all,
i wonder if there is a way of creating an instance of a class and
reach it direcly from any scope in PHP4. basically what i want is:
...
i don't want to:
- declare global $foo,
- use pre-defined $GLOBALS variable,
- or use a::print
You can simulate singletons in PHP 4 as well. But you've just eliminated
every option for accessing a non-local object inside a function. You've got
4 options. Pick one, but I'm fairly certain there is no magical 5th. :-)
On Saturday 01 July 2006 13:02, sempsteen wrote:
> Thanks Larry but i'm
It sounds like your only other option is a singleton, which works only if
you're comfortable having only one instance of a, ever. The following code
also only works in PHP 5.
class A {
static obj;
static instance() {
if (! self::obj instanceof A) {
self::obj = new A();
}
On 7/1/06, chris smith <[EMAIL PROTECTED]> wrote:
On 7/1/06, sempsteen <[EMAIL PROTECTED]> wrote:
> hi all,
> i wonder if there is a way of creating an instance of a class and
> reach it direcly from any scope in PHP4. basically what i want is:
>
> class a
> {
>function print()
>{
>
On 7/1/06, sempsteen <[EMAIL PROTECTED]> wrote:
hi all,
i wonder if there is a way of creating an instance of a class and
reach it direcly from any scope in PHP4. basically what i want is:
class a
{
function print()
{
echo 'sth';
}
}
$a = new a();
and use this "a" instance from
hi all,
i wonder if there is a way of creating an instance of a class and
reach it direcly from any scope in PHP4. basically what i want is:
class a
{
function print()
{
echo 'sth';
}
}
$a = new a();
and use this "a" instance from anywhere ex, in a function that is a
method of anothe
11 matches
Mail list logo