RE: [PHP] What's the use in OOP?

2004-03-31 Thread Peter Albertsson
The OO paradigm maps very closely to problem domains, and is very easy to
model. OO let us build more complex software with less effort.

In general, OO code has more branches and hence use the stack more than
procedural code does. That is why OO code is thought not to be as fast as
procedural code. On the other hand it is easier to build better solutions
when using OOP, and therefore it is often said that applications written in
an OO language is +-10% faster or slower. 

One can use the OO features in PHP without having to worry about performance
penalties. If you are concerned about performance, discussing whether or not
to use OOP in PHP would simply be stupid (don't mean to offend anyone),
there is so many other variables that will have a far bigger impact on
performance than that.

Regards,

Peter Albertsson
Software Engineer and System Architect

-Original Message-
From: Chris Shiflett [mailto:[EMAIL PROTECTED] 
Sent: den 29 mars 2004 23:53
To: Stephen Craton; 'PHP List'
Subject: Re: [PHP] What's the use in OOP?

--- Stephen Craton [EMAIL PROTECTED] wrote:
 I've been reading up on object oriented programming in PHP for a while
 now and I just don't get what's the use in using it. It supposedly
 makes it faster, but I don't really see how in any of my scripts.

Makes it faster in what way? I'm curious to know what you've been reading.

Using objects is generally faster for the programmer and slower for the
computer. YMMV.

 What's the advantage of OOP anyway, and why are so many people using
 it now?

To really understand this, you need to use it. No one can tell you in one
or two lines enough information to explain the entire paradigm or even
convince you of its merits.

The one-liner attempt of mine would be something like:

It helps you associate data with functions that use that data.

There are lots of other things, of course. One method of learning about
this would be to take every OO term (encapsulation, namespacing, etc.) and
find a really good explanation of the term.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming Fall 2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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

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



[PHP] Wrong IP address

2004-03-30 Thread Peter Albertsson
If your request is going through a proxy, $_SERVER[REMOTE_ADDR] will
contain the ip address for the proxy. The proxy might add a
HTTP_X_FORWARDED_FOR header to the request which will contain the ip address
of the client to the proxy, which should be where the request originated. It
is possible for a request to travel through several proxies and then the
HTTP_X_FORWARDED_FOR header will be added several times.

$_SERVER['HTTP_X_FORWARDED_FOR'] if exists will contain the ip address of
where the request originated if the request was proxied.
$_SERVER['HTTP_X_FORWARDED_FOR'] may be an array if the request was proxied
several times.

Regards,

Peter Albertsson

-Original Message-
From: ascll [mailto:[EMAIL PROTECTED] 
Sent: den 30 mars 2004 03:13
To: [EMAIL PROTECTED]
Subject: [PHP] Wrong IP address

Greetings,

I make use of these: -

?php
echo($_SERVER[REMOTE_ADDR]);
?

to get the web IP address for my machine once my PC is connected to
Internet..

Anyway, sometime I get the correct IP address, but sometime NOT.

Does anyone know why?

Thanks in advance.

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

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