Re: [PHP] repetition of tedious references

2007-07-20 Thread Richard Lynch
On Wed, July 18, 2007 9:24 am, Olav Mørkrid wrote: > i didn't know about empty. thanks! Watch out!!! If your code is being distributed on many PHP platforms, the definition of "empty" changed from version to version... Won't matter for the $language you're trying to get at here, but will in othe

Re: [PHP] repetition of tedious references

2007-07-20 Thread Richard Lynch
On Wed, July 18, 2007 7:24 am, Olav Mørkrid wrote: > consider the following statement: > > $language = > isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && > $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? > $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; You can do it nicely in 2: $language = isset($_SERVER['HTTP_ACCEP

Re: [PHP] repetition of tedious references

2007-07-19 Thread Arpad Ray
Olav Mørkrid wrote: i didn't know about empty. thanks! do you have a link to this new php 6 ? : convention? I haven't seen any documentation yet but it currently operates like: ($a ?: $b) === (empty($a) ? $b : $a) with the exception that if $a is unset then an E_NOTICE error is raised. It rem

Re: [PHP] repetition of tedious references

2007-07-19 Thread Chris
tedd wrote: At 5:41 PM -0400 7/19/07, Eric Butera wrote: On 7/19/07, tedd <[EMAIL PROTECTED]> wrote: But, Rasmus gave me this: $action = isset($_GET['action']) ? $_GET['action'] : null; Since you're responding to someone else asking about such things where there is the chance someone can j

Re: [PHP] repetition of tedious references

2007-07-19 Thread tedd
At 5:41 PM -0400 7/19/07, Eric Butera wrote: On 7/19/07, tedd <[EMAIL PROTECTED]> wrote: But, Rasmus gave me this: $action = isset($_GET['action']) ? $_GET['action'] : null; Since you're responding to someone else asking about such things where there is the chance someone can just copy & pa

Re: [PHP] repetition of tedious references

2007-07-19 Thread Instruct ICC
From: tedd <[EMAIL PROTECTED]> Olav: Mine too. But, Rasmus gave me this: $action = isset($_GET['action']) ? $_GET['action'] : null; Which could be translated to: $language = isset ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) ? ($_SERVER["HTTP_ACCEPT_LANGUAGE"]) : "*"; I think that might help. Any

Re: [PHP] repetition of tedious references

2007-07-19 Thread Eric Butera
On 7/19/07, tedd <[EMAIL PROTECTED]> wrote: At 2:24 PM +0200 7/18/07, Olav Mørkrid wrote: >consider the following statement: > >$language = >isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && >$_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? >$_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; > >when using strings in array

Re: [PHP] repetition of tedious references

2007-07-19 Thread Tijnema
On 7/19/07, tedd <[EMAIL PROTECTED]> wrote: At 2:24 PM +0200 7/18/07, Olav Mørkrid wrote: >consider the following statement: > >$language = >isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && >$_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? >$_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; > >when using strings in array

Re: [PHP] repetition of tedious references

2007-07-19 Thread tedd
At 2:24 PM +0200 7/18/07, Olav Mørkrid wrote: consider the following statement: $language = isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; when using strings in arrays that may be non-existing or empty, you have to rep

Re: [PHP] repetition of tedious references

2007-07-18 Thread Jim Lucas
Olav Mørkrid wrote: consider the following statement: $language = isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; when using strings in arrays that may be non-existing or empty, you have to repeat the reference *three*

Re: [PHP] repetition of tedious references

2007-07-18 Thread Olav Mørkrid
i didn't know about empty. thanks! do you have a link to this new php 6 ? : convention? it would be great if php 6 could have a solution for this. php is sweet when it's compact! On 18/07/07, Arpad Ray <[EMAIL PROTECTED]> wrote: You can use empty() to take one of them out, since "0" is presum

Re: [PHP] repetition of tedious references

2007-07-18 Thread Olav Mørkrid
rob, yes i thought of this, you could possible even do function magic($array, $name, $default=null ) { return isset($array[$name]) && $array[$name] ? $array[$name] : $default; } $string = magic($_SERVER, "HTTP_ACCEPT_LANGUAGE", "*") however i wish php would have some built-in support to solve

Re: [PHP] repetition of tedious references

2007-07-18 Thread Olav Mørkrid
al Message - From: "Olav Mørkrid" <[EMAIL PROTECTED]> To: "PHP General List" Sent: Wednesday, July 18, 2007 1:24 PM Subject: [PHP] repetition of tedious references > consider the following statement: > > $language = > isset($_SERVER["HTTP_ACCEPT_LANGU

Re: [PHP] repetition of tedious references

2007-07-18 Thread Stut
quot;" ? $variable : "*"; } The isset is redundant here. It's been passed as an argument so it definitely exists. -Stut -- http://stut.net/ - Original Message - From: "Olav Mørkrid" <[EMAIL PROTECTED]> To: "PHP General List" Sent: W

Re: [PHP] repetition of tedious references

2007-07-18 Thread C.R.Vegelin
-- From: "Olav Mørkrid" <[EMAIL PROTECTED]> To: "PHP General List" Sent: Wednesday, July 18, 2007 1:24 PM Subject: [PHP] repetition of tedious references consider the following statement: $language = isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER

Re: [PHP] repetition of tedious references

2007-07-18 Thread Arpad Ray
Olav Mørkrid wrote: consider the following statement: $language = isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; when using strings in arrays that may be non-existing or empty, you have to repeat the reference *three*

[PHP] repetition of tedious references

2007-07-18 Thread Olav Mørkrid
consider the following statement: $language = isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && $_SERVER["HTTP_ACCEPT_LANGUAGE"] != "" ? $_SERVER["HTTP_ACCEPT_LANGUAGE"] : "*"; when using strings in arrays that may be non-existing or empty, you have to repeat the reference *three* times, which gets ex