[PHP] changing NULL behavior in PHP arithmetic

2010-04-15 Thread cr.vegelin
Hi All,

Is there an option in PHP to change the behavior of NULL in PHP functions ?
Now PHP uses NULL as a 0 (zero) for arithmetic, for example:
NULL + 6 = 6
NULL * 6 = 0
NULL / 6 = 0
6 / NULL = Division by zero

What I need is the same behavior as #N/A (or =NA()) in Excel, where:
#N/A + 6 = #N/A
#N/A * 6 = #N/A
#N/A / 6 = #N/A
6 / #N/A = #N/A

because arithmetic operations with "Unknown" operands should result to 
"Unknown" ...

TIA, Cor


Re: [PHP] changing NULL behavior in PHP arithmetic

2010-04-15 Thread Ashley Sheridan
On Thu, 2010-04-15 at 09:46 +0200, cr.vege...@gmail.com wrote:

> Hi All,
> 
> Is there an option in PHP to change the behavior of NULL in PHP functions ?
> Now PHP uses NULL as a 0 (zero) for arithmetic, for example:
> NULL + 6 = 6
> NULL * 6 = 0
> NULL / 6 = 0
> 6 / NULL = Division by zero
> 
> What I need is the same behavior as #N/A (or =NA()) in Excel, where:
> #N/A + 6 = #N/A
> #N/A * 6 = #N/A
> #N/A / 6 = #N/A
> 6 / #N/A = #N/A
> 
> because arithmetic operations with "Unknown" operands should result to 
> "Unknown" ...
> 
> TIA, Cor


You can't really, because PHP is a loosely typed language, which means
it silently converts values as required by the situation. When you use
mathematical operators, PHP converts the values to numbers, and NULL
maps to a 0 (as does the boolean false and an empty string)

The only way I can see to fix your problem is to check the value of the
variables you are working on with something like is_int()

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Re: how to overload accessible methods

2010-04-15 Thread Richard Quadling
On 13 April 2010 17:25, Ryan Sun  wrote:
> this is a class for corntab job, and the validation is very simple,
> just check if the status of user is active when cron job runs, if not,
> throws an exception, other developers won't want to overwrite this
> validation.
> which method of user class will be called is configurable via website
> backed page(we write the name of methods directly in to  schedule
> table).
> Using private methods will solve the problem but since we write public
> methods for all the other cron classes, I just want to keep the style
> to make less confusion.
>
> On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham  wrote:
>> Ryan Sun wrote:
>>> I'm writing an abstract parent class which only contain a validate
>>> method, other developers will extend this class and add many new
>>> public methods, every new methods will need to perform a validate
>>> first.  Won't it be good if validate get called automatically before
>>> every method call so that they don't have to write more code and they
>>> won't miss this validate?
>>
>> This may call for a back to roots approach, what exactly are you trying
>> to accomplish, as in: what is the validation doing?
>>
>> perhaps if we see the full picture, we can recommend another perhaps
>> more suited approach to the full thing, feel free to post the full code
>> if you want / can, the more info the better!
>>
>> Regards,
>>
>> Nathan
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Would this be better ...

abstract class baseValidate() {
 final public function __construct($params) {
  // Determine if user is active.
 // If OK, then call abstract function postConstruct($params)
 }

 abstract function postConstruct($params);
}


You can't override the constructor, so the validation will always be
called. The developer's can implement their own postConstruct as if
they where extending __construct.



-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] changing NULL behavior in PHP arithmetic

2010-04-15 Thread kranthi
>> because arithmetic operations with "Unknown" operands should result to 
>> "Unknown" ...
in PHP "Unknown" values are represented by NaN, not NULL
http://php.net/manual/en/function.is-nan.php

but what surprises me is
is_nan(6/0) = (bool)false (along with a warning)

>> Now PHP uses NULL as a 0 (zero) for arithmetic
I dont expect anything different, because intval(null) is 0.

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



Re: [PHP] changing NULL behavior in PHP arithmetic

2010-04-15 Thread cr.vegelin
  From: Ashley Sheridan 
  To: cr.vege...@gmail.com 
  Cc: php-general@lists.php.net 
  Sent: Thursday, April 15, 2010 10:08 AM
  Subject: Re: [PHP] changing NULL behavior in PHP arithmetic


  On Thu, 2010-04-15 at 09:46 +0200, cr.vege...@gmail.com wrote: 
Hi All,

Is there an option in PHP to change the behavior of NULL in PHP functions ?
Now PHP uses NULL as a 0 (zero) for arithmetic, for example:
NULL + 6 = 6
NULL * 6 = 0
NULL / 6 = 0
6 / NULL = Division by zero

What I need is the same behavior as #N/A (or =NA()) in Excel, where:
#N/A + 6 = #N/A
#N/A * 6 = #N/A
#N/A / 6 = #N/A
6 / #N/A = #N/A

because arithmetic operations with "Unknown" operands should result to 
"Unknown" ...

TIA, Cor

  You can't really, because PHP is a loosely typed language, which means it 
silently converts values as required by the situation. When you use 
mathematical operators, PHP converts the values to numbers, and NULL maps to a 
0 (as does the boolean false and an empty string)

  The only way I can see to fix your problem is to check the value of the 
variables you are working on with something like is_int()

Thanks,
Ash
http://www.ashleysheridan.co.uk


   

Thanks for replying. 
I tried the predefined PHP constant NAN. 
However, NAN + 6 = 6, so NAN is can't be used either.

To bypass the problem, I now use is_null().
is_int() can also be used, but does it have advantages over is_null() ?

Thanks, Cor

Re: [PHP] Basic switch statement

2010-04-15 Thread tedd

At 4:13 PM -0400 4/14/10, Al wrote:
Incidentally, about formatting scripts, one of the reasons I like 
phpEdit is that it has a terrific code beautifier.  You can set it 
for phpDoc or Pear rendering. And, it auto indents, etc. as you 
enter stuff.


Al...


Unfortunately, there is no phpEdit version for the Mac.

Currently, I use GoLive (without all the WYSIWYG bloatware), but it 
limitations are showing. I like Eclipse, but the learning curve is 
high and has more features than I need.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Basic switch statement

2010-04-15 Thread Bastien Koert
On Thu, Apr 15, 2010 at 8:55 AM, tedd  wrote:
> At 4:13 PM -0400 4/14/10, Al wrote:
>>
>> Incidentally, about formatting scripts, one of the reasons I like phpEdit
>> is that it has a terrific code beautifier.  You can set it for phpDoc or
>> Pear rendering. And, it auto indents, etc. as you enter stuff.
>>
>> Al...
>
> Unfortunately, there is no phpEdit version for the Mac.
>
> Currently, I use GoLive (without all the WYSIWYG bloatware), but it
> limitations are showing. I like Eclipse, but the learning curve is high and
> has more features than I need.
>
> Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Sorry, should have copied the list

try netbeans  http://netbeans.org/kb/articles/mac.html



-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Basic switch statement

2010-04-15 Thread Ashley Sheridan
On Thu, 2010-04-15 at 08:55 -0400, tedd wrote:

> At 4:13 PM -0400 4/14/10, Al wrote:
> >Incidentally, about formatting scripts, one of the reasons I like 
> >phpEdit is that it has a terrific code beautifier.  You can set it 
> >for phpDoc or Pear rendering. And, it auto indents, etc. as you 
> >enter stuff.
> >
> >Al...
> 
> Unfortunately, there is no phpEdit version for the Mac.
> 
> Currently, I use GoLive (without all the WYSIWYG bloatware), but it 
> limitations are showing. I like Eclipse, but the learning curve is 
> high and has more features than I need.
> 
> Cheers,
> 
> tedd
> 
> -- 
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 


Have you tried Coder on the Mac? Most developers I know who use Macs
(it's not the oxymoron it sounds! :p ) tend to use Coder. It's pretty
good, and while I've not used it myself, I've seen enough to like it. In
a perfect world my editor would be somewhere between Coder and Kate (the
KDE Advanced Text Editor) with the best bits of both thrown in.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] class attributes and __construct

2010-04-15 Thread Ashley Sheridan
I think this is probably going to end up as one of those coders'
preference type of things, but I was wondering what was considered the
general best approach.

When creating a class, you can define default values for the object in
the class itself, and within the __construct function. Now, while I see
the advantage to using __construct to set properties that might depend
on a variable, what would be the best approach for any values that might
likely remain at a default value and only ever change in a few rare
circumstances?

For example:

class Person
{
public $right_handed = true;

function __construct($name, $height)
{
$this->name = $name;
$this-height = $height;
}

function set_hand($side)
{
if($side == 'left'
{
$this->right_handed = false;
}
else
{
$this->right_handed = true;
}
}

}

Now, this is a simple example, but a value like $right_handed should
only ever change if it's not the typical. As most people are
right-handed it would make sense to set it to true and allow it to be
changed to false as necessary. What I'm wonder is, where is the best
place to set it to true, in the list of class properties at the top, or
in the __construct() function?

I know I could move it to __construct and give it a default value in the
arguments list, but that brings it's own problems. What if the argument
list grows too big, and which attribute would be deemed more important
than another that you might want to override it without specifying every
other? Is there a rule of thumb as to what belongs in __construct and
what does not?

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] class attributes and __construct

2010-04-15 Thread Tommy Pham
Hi Ashley,

> -Original Message-
> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> Sent: Thursday, April 15, 2010 6:38 AM
> To: PHP General List
> Subject: [PHP] class attributes and __construct
> 
> I think this is probably going to end up as one of those coders'
> preference type of things, but I was wondering what was considered the
> general best approach.
> 
> When creating a class, you can define default values for the object in
> the class itself, and within the __construct function. Now, while I see
> the advantage to using __construct to set properties that might depend
> on a variable, what would be the best approach for any values that
> might
> likely remain at a default value and only ever change in a few rare
> circumstances?
> 
> For example:
> 
> class Person
> {
> public $right_handed = true;

I recommend setting it to private or protected instead of public to protect the 
integrity of the app.  And add a get method/function to obtain the value.

> function __construct($name, $height)
> {
> $this->name = $name;
> $this-height = $height;
> }
> 
> function set_hand($side)
> {
> if($side == 'left'
> {
> $this->right_handed = false;
> }
> else
> {
> $this->right_handed = true;
> }
> }
> 
> }
> 
> Now, this is a simple example, but a value like $right_handed should
> only ever change if it's not the typical. As most people are
> right-handed it would make sense to set it to true and allow it to be
> changed to false as necessary. What I'm wonder is, where is the best
> place to set it to true, in the list of class properties at the top, or
> in the __construct() function?
> 
> I know I could move it to __construct and give it a default value in
> the
> arguments list, but that brings it's own problems. What if the argument
> list grows too big, and which attribute would be deemed more important
> than another that you might want to override it without specifying
> every
> other? Is there a rule of thumb as to what belongs in __construct and
> what does not?
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> 

As for setting the default value in the construct, I recommend not to because 
should PHP support overloading later, you can then have another method/function 
to change its non-default value along with the initial parameters for the 
class.  I use the constructor to set initial parameters for the class or 
initialize any class specific settings such as connection for DBAL.

Regards,
Tommy


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



RE: [PHP] class attributes and __construct

2010-04-15 Thread Ashley Sheridan
On Thu, 2010-04-15 at 07:42 -0700, Tommy Pham wrote:

> Hi Ashley,
> 
> > -Original Message-
> > From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> > Sent: Thursday, April 15, 2010 6:38 AM
> > To: PHP General List
> > Subject: [PHP] class attributes and __construct
> > 
> > I think this is probably going to end up as one of those coders'
> > preference type of things, but I was wondering what was considered the
> > general best approach.
> > 
> > When creating a class, you can define default values for the object in
> > the class itself, and within the __construct function. Now, while I see
> > the advantage to using __construct to set properties that might depend
> > on a variable, what would be the best approach for any values that
> > might
> > likely remain at a default value and only ever change in a few rare
> > circumstances?
> > 
> > For example:
> > 
> > class Person
> > {
> > public $right_handed = true;
> 
> I recommend setting it to private or protected instead of public to protect 
> the integrity of the app.  And add a get method/function to obtain the value.
> 
> > function __construct($name, $height)
> > {
> > $this->name = $name;
> > $this-height = $height;
> > }
> > 
> > function set_hand($side)
> > {
> > if($side == 'left'
> > {
> > $this->right_handed = false;
> > }
> > else
> > {
> > $this->right_handed = true;
> > }
> > }
> > 
> > }
> > 
> > Now, this is a simple example, but a value like $right_handed should
> > only ever change if it's not the typical. As most people are
> > right-handed it would make sense to set it to true and allow it to be
> > changed to false as necessary. What I'm wonder is, where is the best
> > place to set it to true, in the list of class properties at the top, or
> > in the __construct() function?
> > 
> > I know I could move it to __construct and give it a default value in
> > the
> > arguments list, but that brings it's own problems. What if the argument
> > list grows too big, and which attribute would be deemed more important
> > than another that you might want to override it without specifying
> > every
> > other? Is there a rule of thumb as to what belongs in __construct and
> > what does not?
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> 
> As for setting the default value in the construct, I recommend not to because 
> should PHP support overloading later, you can then have another 
> method/function to change its non-default value along with the initial 
> parameters for the class.  I use the constructor to set initial parameters 
> for the class or initialize any class specific settings such as connection 
> for DBAL.
> 
> Regards,
> Tommy
> 


Maybe my example wasn't the best, but I did mean that my public variable
there was a value that should be initially set with the class
initialisation I realise the differences between public, private and
protected variables, that wasn't my question. What I wanted to know was
if there was a convention about what specific properties should be set
through the public $var = method and what should be left for the
__construct function?

For example, which would be better here (assuming a variable number of
variables that might be set this way:

class House
{
public $roof = true;
}

class House
{
function __construct()
{
$this->roof = true;
}
}

Aside from the amount of typing (which isn't a serious consideration for
me anyway) and assuming that such variable initialisation will not rely
on variable input but will be fixed with the option of a class method to
change the value later, what would be the preferred method and are there
any caveats I'm unaware of right now (as I'm aware of none so far) to
either method?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] class attributes and __construct

2010-04-15 Thread Fernando

Hello Ashely,

I would initialize the variable when I'm defining it as there isn't much 
of a point of doing it in the constructor unless I'm having the value 
changed by a parameter.


In my opinion:

class House
{
public $roof = true;
}

is the way to go.

Fernando.

On 15/04/2010 11:54, Ashley Sheridan wrote:

On Thu, 2010-04-15 at 07:42 -0700, Tommy Pham wrote:

   

Hi Ashley,

 

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
Sent: Thursday, April 15, 2010 6:38 AM
To: PHP General List
Subject: [PHP] class attributes and __construct

I think this is probably going to end up as one of those coders'
preference type of things, but I was wondering what was considered the
general best approach.

When creating a class, you can define default values for the object in
the class itself, and within the __construct function. Now, while I see
the advantage to using __construct to set properties that might depend
on a variable, what would be the best approach for any values that
might
likely remain at a default value and only ever change in a few rare
circumstances?

For example:

class Person
{
 public $right_handed = true;
   

I recommend setting it to private or protected instead of public to protect the 
integrity of the app.  And add a get method/function to obtain the value.

 

 function __construct($name, $height)
 {
 $this->name = $name;
 $this-height = $height;
 }

 function set_hand($side)
 {
 if($side == 'left'
 {
 $this->right_handed = false;
 }
 else
 {
 $this->right_handed = true;
 }
 }

}

Now, this is a simple example, but a value like $right_handed should
only ever change if it's not the typical. As most people are
right-handed it would make sense to set it to true and allow it to be
changed to false as necessary. What I'm wonder is, where is the best
place to set it to true, in the list of class properties at the top, or
in the __construct() function?

I know I could move it to __construct and give it a default value in
the
arguments list, but that brings it's own problems. What if the argument
list grows too big, and which attribute would be deemed more important
than another that you might want to override it without specifying
every
other? Is there a rule of thumb as to what belongs in __construct and
what does not?

Thanks,
Ash
http://www.ashleysheridan.co.uk

   

As for setting the default value in the construct, I recommend not to because 
should PHP support overloading later, you can then have another method/function 
to change its non-default value along with the initial parameters for the 
class.  I use the constructor to set initial parameters for the class or 
initialize any class specific settings such as connection for DBAL.

Regards,
Tommy

 


Maybe my example wasn't the best, but I did mean that my public variable
there was a value that should be initially set with the class
initialisation I realise the differences between public, private and
protected variables, that wasn't my question. What I wanted to know was
if there was a convention about what specific properties should be set
through the public $var = method and what should be left for the
__construct function?

For example, which would be better here (assuming a variable number of
variables that might be set this way:

class House
{
 public $roof = true;
}

class House
{
 function __construct()
 {
 $this->roof = true;
 }
}

Aside from the amount of typing (which isn't a serious consideration for
me anyway) and assuming that such variable initialisation will not rely
on variable input but will be fixed with the option of a class method to
change the value later, what would be the preferred method and are there
any caveats I'm unaware of right now (as I'm aware of none so far) to
either method?

Thanks,
Ash
http://www.ashleysheridan.co.uk



   


RE: [PHP] class attributes and __construct

2010-04-15 Thread Tommy Pham
> -Original Message-
> From: Fernando [mailto:ferna...@ggtours.ca]
> Sent: Thursday, April 15, 2010 10:24 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] class attributes and __construct
> 
> Hello Ashely,
> 
> I would initialize the variable when I'm defining it as there isn't
> much
> of a point of doing it in the constructor unless I'm having the value
> changed by a parameter.
> 
> In my opinion:
> 
> class House
> {
>  public $roof = true;
> }
> 
> is the way to go.
> 
> Fernando.

That's what I meant.  IMO, it's also a micro optimization since it doesn't need 
an extra step of looking the variable and assigning the value when it's not 
needed.  Plus, it allows better polymorphism through methods/functions.

Regards,
Tommy

> 
> On 15/04/2010 11:54, Ashley Sheridan wrote:
> > On Thu, 2010-04-15 at 07:42 -0700, Tommy Pham wrote:
> >
> >
> >> Hi Ashley,
> >>
> >>
> >>> -Original Message-
> >>> From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk]
> >>> Sent: Thursday, April 15, 2010 6:38 AM
> >>> To: PHP General List
> >>> Subject: [PHP] class attributes and __construct
> >>>
> >>> I think this is probably going to end up as one of those coders'
> >>> preference type of things, but I was wondering what was considered
> the
> >>> general best approach.
> >>>
> >>> When creating a class, you can define default values for the object
> in
> >>> the class itself, and within the __construct function. Now, while I
> see
> >>> the advantage to using __construct to set properties that might
> depend
> >>> on a variable, what would be the best approach for any values that
> >>> might
> >>> likely remain at a default value and only ever change in a few rare
> >>> circumstances?
> >>>
> >>> For example:
> >>>
> >>> class Person
> >>> {
> >>>  public $right_handed = true;
> >>>
> >> I recommend setting it to private or protected instead of public to
> protect the integrity of the app.  And add a get method/function to
> obtain the value.
> >>
> >>
> >>>  function __construct($name, $height)
> >>>  {
> >>>  $this->name = $name;
> >>>  $this-height = $height;
> >>>  }
> >>>
> >>>  function set_hand($side)
> >>>  {
> >>>  if($side == 'left'
> >>>  {
> >>>  $this->right_handed = false;
> >>>  }
> >>>  else
> >>>  {
> >>>  $this->right_handed = true;
> >>>  }
> >>>  }
> >>>
> >>> }
> >>>
> >>> Now, this is a simple example, but a value like $right_handed
> should
> >>> only ever change if it's not the typical. As most people are
> >>> right-handed it would make sense to set it to true and allow it to
> be
> >>> changed to false as necessary. What I'm wonder is, where is the
> best
> >>> place to set it to true, in the list of class properties at the
> top, or
> >>> in the __construct() function?
> >>>
> >>> I know I could move it to __construct and give it a default value
> in
> >>> the
> >>> arguments list, but that brings it's own problems. What if the
> argument
> >>> list grows too big, and which attribute would be deemed more
> important
> >>> than another that you might want to override it without specifying
> >>> every
> >>> other? Is there a rule of thumb as to what belongs in __construct
> and
> >>> what does not?
> >>>
> >>> Thanks,
> >>> Ash
> >>> http://www.ashleysheridan.co.uk
> >>>
> >>>
> >> As for setting the default value in the construct, I recommend not
> to because should PHP support overloading later, you can then have
> another method/function to change its non-default value along with the
> initial parameters for the class.  I use the constructor to set initial
> parameters for the class or initialize any class specific settings such
> as connection for DBAL.
> >>
> >> Regards,
> >> Tommy
> >>
> >>
> >
> > Maybe my example wasn't the best, but I did mean that my public
> variable
> > there was a value that should be initially set with the class
> > initialisation I realise the differences between public, private and
> > protected variables, that wasn't my question. What I wanted to know
> was
> > if there was a convention about what specific properties should be
> set
> > through the public $var = method and what should be left for the
> > __construct function?
> >
> > For example, which would be better here (assuming a variable number
> of
> > variables that might be set this way:
> >
> > class House
> > {
> >  public $roof = true;
> > }
> >
> > class House
> > {
> >  function __construct()
> >  {
> >  $this->roof = true;
> >  }
> > }
> >
> > Aside from the amount of typing (which isn't a serious consideration
> for
> > me anyway) and assuming that such variable initialisation will not
> rely
> > on variable input but will be fixed with the option of a class method
> to
> > change the value later, what would be the preferred method and are
> there
> > any caveats I'm unaware of right now (as I'm aware of none so far) to
> > eithe

[PHP] Zip Search

2010-04-15 Thread Jack
Hello All,

 

Can anyone recommend a good open source zip code search application and
database?

 

 

Thanks,

 

Jack

 



Re: [PHP] Zip Search

2010-04-15 Thread Nathan Nobbe
On Thu, Apr 15, 2010 at 1:21 PM, Jack  wrote:

> Hello All,
>
> Can anyone recommend a good open source zip code search application and
> database?
>

depends on what you want, u.s., canada & mexico are pretty easy to find but
for other non domestic countries if you find something good feel free to
share :)

for a nice freebie that works on u.s. locations, snag the geoip extension
from pecl -

http://php.net/manual/en/book.geoip.php

-nathan


RE: [PHP] Zip Search

2010-04-15 Thread Tommy Pham
> -Original Message-
> From: Nathan Nobbe [mailto:quickshif...@gmail.com]
> Sent: Thursday, April 15, 2010 12:41 PM
> To: Jack
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Zip Search
> 
> On Thu, Apr 15, 2010 at 1:21 PM, Jack  wrote:
> 
> > Hello All,
> >
> > Can anyone recommend a good open source zip code search application
> and
> > database?
> >
> 
> depends on what you want, u.s., canada & mexico are pretty easy to find
> but
> for other non domestic countries if you find something good feel free
> to
> share :)
> 
> for a nice freebie that works on u.s. locations, snag the geoip
> extension
> from pecl -
> 
> http://php.net/manual/en/book.geoip.php
> 
> -nathan

IIRC, geoip is lookup based on host name or IP address for country, region, 
city, etc... similar to whois for DNS.  I think the OP wants to look geographic 
information, such as city, county, state/province, etc..., based on a given zip 
code like 92723.

Regards,
Tommy


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



Re: [PHP] Zip Search

2010-04-15 Thread Nathan Nobbe
On Thu, Apr 15, 2010 at 1:51 PM, Tommy Pham  wrote:

> > -Original Message-
> > From: Nathan Nobbe [mailto:quickshif...@gmail.com]
> > Sent: Thursday, April 15, 2010 12:41 PM
> > To: Jack
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] Zip Search
> >
> > On Thu, Apr 15, 2010 at 1:21 PM, Jack  wrote:
> >
> > > Hello All,
> > >
> > > Can anyone recommend a good open source zip code search application
> > and
> > > database?
> > >
> >
> > depends on what you want, u.s., canada & mexico are pretty easy to find
> > but
> > for other non domestic countries if you find something good feel free
> > to
> > share :)
> >
> > for a nice freebie that works on u.s. locations, snag the geoip
> > extension
> > from pecl -
> >
> > http://php.net/manual/en/book.geoip.php
> >
> > -nathan
>
> IIRC, geoip is lookup based on host name or IP address for country, region,
> city, etc... similar to whois for DNS.  I think the OP wants to look
> geographic information, such as city, county, state/province, etc..., based
> on a given zip code like 92723.
>

ahh, perhaps a hasty reply on my part - heres a nice freebie mentioned by
geoip -

http://geocoder.ibegin.com/downloads.php

-nathan


Re: [PHP] Zip Search

2010-04-15 Thread Jason Pruim


On Apr 15, 2010, at 3:21 PM, Jack wrote:


Hello All,



Can anyone recommend a good open source zip code search application  
and

database?


If it's us zip's you want... I'd go straight to the source... 
http://www.usps.com/zip4/welcome.htm?from=home_header&page=findazipcode

The post office also does have API's for hooking into it if you can  
handle the restrictions since they are the government :)


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



Re: [PHP] Basic switch statement

2010-04-15 Thread Jason Pruim


On Apr 15, 2010, at 8:55 AM, tedd wrote:


At 4:13 PM -0400 4/14/10, Al wrote:
Incidentally, about formatting scripts, one of the reasons I like  
phpEdit is that it has a terrific code beautifier.  You can set it  
for phpDoc or Pear rendering. And, it auto indents, etc. as you  
enter stuff.


Al...


Unfortunately, there is no phpEdit version for the Mac.

Currently, I use GoLive (without all the WYSIWYG bloatware), but it  
limitations are showing. I like Eclipse, but the learning curve is  
high and has more features than I need.



Hey tedd

I just recently started using netbeans and it looks like it may fit  
the bill... it's simple enough to understand but can be extended if  
you want to. It also runs better on my Mac then Eclipse ever did. Just  
something that might be worth checking out :)




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



Re: [PHP] Basic switch statement

2010-04-15 Thread Jason Pruim


On Apr 15, 2010, at 9:24 AM, Ashley Sheridan wrote:


On Thu, 2010-04-15 at 08:55 -0400, tedd wrote:





Have you tried Coder on the Mac? Most developers I know who use Macs
(it's not the oxymoron it sounds! :p )


Most Mac people would say the morons use Windows ;)  But that's  
another story for another list! :)




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



Re: [PHP] Basic switch statement

2010-04-15 Thread Adam Richardson
On Thu, Apr 15, 2010 at 5:55 PM, Jason Pruim wrote:

>
> On Apr 15, 2010, at 8:55 AM, tedd wrote:
>
>  At 4:13 PM -0400 4/14/10, Al wrote:
>>
>>> Incidentally, about formatting scripts, one of the reasons I like phpEdit
>>> is that it has a terrific code beautifier.  You can set it for phpDoc or
>>> Pear rendering. And, it auto indents, etc. as you enter stuff.
>>>
>>> Al...
>>>
>>
>> Unfortunately, there is no phpEdit version for the Mac.
>>
>> Currently, I use GoLive (without all the WYSIWYG bloatware), but it
>> limitations are showing. I like Eclipse, but the learning curve is high and
>> has more features than I need.
>>
>
>
> Hey tedd
>
> I just recently started using netbeans and it looks like it may fit the
> bill... it's simple enough to understand but can be extended if you want to.
> It also runs better on my Mac then Eclipse ever did. Just something that
> might be worth checking out :)
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
+1 Netbeans

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] class attributes and __construct

2010-04-15 Thread Larry Garfield
On Thursday 15 April 2010 08:37:40 am Ashley Sheridan wrote:

> I know I could move it to __construct and give it a default value in the
> arguments list, but that brings it's own problems. What if the argument
> list grows too big, and which attribute would be deemed more important
> than another that you might want to override it without specifying every
> other? Is there a rule of thumb as to what belongs in __construct and
> what does not?
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk

I tend to favor setting the default with the property itself rather than in 
the constructor, even if I expect the constructor to specify it.  I really 
really hate having undefined variables. :-)  So even if, for instance, I'm 
going to pass in a db connection object in the constructor I will define it in 
the class and set it to NULL rather than not setting to anything.

OK, I'm a little OCD, but it works. :-)  

--Larry Garfield

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