[PHP] How to address __FILE__ constant in extensions?

2003-07-16 Thread Sam Baum
Hi there,

i am not getting it. How can I read out the magical __FILE__ constant inside
an _extension_ (a loadable module) ? Its not in symbol_table, so where is
it?


bg

Sam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: classes v. functions

2003-07-19 Thread Sam Baum
Hi,

am Friday 18 July 2003 23:08 schrieb Andu:

> This may show my ignorance or my refusal to take for granted something I
> don't fully understand but I have a hard time figuring out the advantage
> of using classes as opposed to just functions. I am certainly new to php
> and at first sight classes seemed to cut a lot of corners but so do
> functions (with which I have more experience). The more I read about
> classes the deeper the confusion. Anyone can enlighten me?

Im programming for a few years now in PHP. After trying to use classes i
dont see their point either. In most cases if i need a class-like structure
i do something like this:

function thing_new() {
return ++$GLOBALS['thing_resource'];
}

function thing_put($stuff, $res=NULL) {
if (is_null($res)) $res = $GLOBALS['thing_resource'];
$GLOBALS['thing_stuff'][$res] = $stuff;
}

function thing_get($stuff, $res=NULL) {
if (is_null($res)) $res = $GLOBALS['thing_resource'];
return $GLOBALS['thing_stuff'][$res];
}

Because there is no constraint to be more OO like in Java it doesnt makes
sense. And this way you are more flexible.


bg

Sam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: classes v. functions

2003-07-19 Thread Sam Baum
Hi there, 

am Saturday 19 July 2003 16:30 schrieb Curt Zirzow:

> Sam Baum <[EMAIL PROTECTED]> wrote:
>> Hi,
>> 
>> am Friday 18 July 2003 23:08 schrieb Andu:
>> 
>> > This may show my ignorance or my refusal to take for granted something
>> > I don't fully understand but I have a hard time figuring out the
>> > advantage of using classes as opposed to just functions. I am certainly
>> > new to php and at first sight classes seemed to cut a lot of corners
>> > but so do functions (with which I have more experience). The more I
>> > read about classes the deeper the confusion. Anyone can enlighten me?
>> 
>> Im programming for a few years now in PHP. After trying to use classes i
>> dont see their point either. In most cases if i need a class-like
>> structure i do something like this:
>> 
>> function thing_new() {
>> return ++$GLOBALS['thing_resource'];
>> }
> 
> The biggest thing classes do is resolve name space issues, even with
> this method you have namespace issues with your function name and your
> variables.  

Sure i have to add and take care of the namespaces myself, but thats it and
the amount mental work compared to designing a class is imho lesser in my
way. And most times only 1 object of a class gets instanciated, which is to
much overhead in an application. And then u dont even need my construct.
And if you dont create an object and call the function in an static way
(via ::), then the whole benefit of the associated data is gone anyway and
the only thing you have is the namespace. So i dont give the Parser the
challenge of preparing a class representation and keep it simple. And at
last: no more copied objects. 

> A big downfall with classes, however is there speed.  Benchmarking a
> function call vs. a class->method call, results in a significant
> difference and even more if your using a lot of classes.

Ok i just assumed that, but good to know for sure. 



Sam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Passing Serialized Array via Hidden field

2003-07-21 Thread Sam Baum
am Monday 21 July 2003 09:24 schrieb Andrei Verovski:

> I am need to pass serialized assotiative array via form hidden field
> (not GET or POST). 

What does this mean? If you dont use GET or POST your form cant be
submitted.

> In order to do it, I did the following:
> urlencode(serialize($my_array)). However, after retrieving data from
> hidden field and unserialize I've got junk.

Just guessing: tried it w/o urlencode?


Sam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] classes v. functions

2003-07-23 Thread Sam Baum
Hi,

am Wednesday 23 July 2003 11:48 schrieb Joel Rees:

> (You know that $accesses->count and $accesses->resetCounter() are at
> least declared in the same class declaration. $accesses_count and
> accesses_resetCounter() could be declared in entirely unrelated include
> files for entirely different purposes.)

That is the only benefit. But it's not OOP. If you need namespaces and can't
take care of them w/o misuse of a semi-OOP construct youre not any more
efficient with it.

>> Is there any performance benefit one way or the other?
> 
> Programmer performance?
> 
>> I used EZ_Sql which is cool but didn't seem to speed things up in
>> comparison to the said include file.
>> Still don't see the beef.
> 
> Execution speed isn't all that matters. In fact, speed is not the point
> at all.

Then you must be an PHPNuke or Typo3-programmer, beeing lucky to get at
least 1 request per second ;). 

Don't take it hard, but If you had ever been in computer-science
[school|college|...] you would know that speed is all that matters.


bg

Sam

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php