Re: [PHP] control structure

2011-08-04 Thread Chris Stinemetz
> >        // This part makes no sense they are not logged in and they have a > level of 1 or 2 ? Yes. It might not be the best approach, but I am assigning the user a value: 1, 2, or 3 while they create an account. This will limit what they will be able to post. For example I only want users with

RE: [PHP] control structure

2011-08-04 Thread admin
> -Original Message- > From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] > Sent: Thursday, August 04, 2011 11:34 PM > To: PHP General > Subject: [PHP] control structure > > I have a php script with a simple condition. If it is not satisfied I > want to exit the script otherwise I wan

Re: [PHP] Control structure - easier way than repeating conditions in IF?

2004-04-30 Thread Neil Freeman
Why not just use a switch?... switch ($x) { case $a: case $b: case $c: case $d: //do whatever you need break; default: //catch any other values here break; } Neil BOOT wrote: **

RE: [PHP] Control structure - easier way than repeating conditions in IF?

2004-04-30 Thread Gryffyn, Trevor
You could do something like this: $valuesarr = array($a,$b,$c,$d); If (in_array($x,$valuesarr)) { # do something } Or I guess even: If (in_array($x,array($a,$b,$c,$d))) { # do something } I don't know if your method or this method have better performance but it's a little eas

Re: [PHP] Control Structure Syntax Question

2004-03-10 Thread Michal Migurski
>$x ? xxx : xxx > >But it makes your code less readable IMHO and offers no tangible benefit >whatsoever. It offers the tangible benefit of evaluating to something: return (isset($foo) ? $foo : $bar); $query = "select * from foo" .(isset($bar) ? " where bar = ${ba

Re: [PHP] Control Structure Syntax Question

2004-03-09 Thread trlists
On 9 Mar 2004 Richard Davey wrote: > $x ? xxx : xxx > > But it makes your code less readable IMHO and offers no tangible > benefit whatsoever. Ah, to each his/her own I guess ... I actually find: $value = ($condition ? $val1 : $val2); easier to read than: if ($condition)

Re: [PHP] Control Structure Syntax Question

2004-03-09 Thread Justin Patrin
Ahbaid Gaffoor wrote: Yeah, but if my code is less readable, my job security goes up ;) (Kidding) Thanks for all your help folks, that's what I needed. regards Ahbaid Richard Davey wrote: Hello Ahbaid, Tuesday, March 9, 2004, 11:42:21 PM, you wrote: AG> Someone had posted a tip for using a

Re: [PHP] Control Structure Syntax Question

2004-03-09 Thread Ahbaid Gaffoor
Yeah, but if my code is less readable, my job security goes up ;) (Kidding) Thanks for all your help folks, that's what I needed. regards Ahbaid Richard Davey wrote: Hello Ahbaid, Tuesday, March 9, 2004, 11:42:21 PM, you wrote: AG> Someone had posted a tip for using an abbreviated form of a

Re: [PHP] Control Structure Syntax Question

2004-03-09 Thread Richard Davey
Hello Ahbaid, Tuesday, March 9, 2004, 11:42:21 PM, you wrote: AG> Someone had posted a tip for using an abbreviated form of an if.. else AG> structure... AG> It looked something like: AG> $x : action1 : action2; $x ? xxx : xxx But it makes your code less readable IMHO and offers no tangible b

Re: [PHP] Control Structure Syntax Question

2004-03-09 Thread daniel
$x ? action1 : action2; > structure... > > It looked something like: > > $x : action1 : action2; > > I'm trying to shorten having to do the following: > > if ($x) { > action1; > } else { > action 2; > } > > can someone please post the syntax if they know it? I am reading the > fine documentatio

Re: [PHP] Control Structure problem

2003-09-17 Thread David Robley
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says... > yeah, i really like using cases they work well and especially if you want to > do something different for different values, i forgot about that, its a good > way to do it, > > does php have case else? cuz that is a really handy thing in

Re: [PHP] Control Structure problem

2003-09-16 Thread Chris Shiflett
--- Eugene Lee <[EMAIL PROTECTED]> wrote: > : switch (true) { > : case ($var === 'TEST-1')?true:false: > : case ($var === 'TEST-2')?true:false: > : case ($var === 'TEST-2')?true:false: > :do something > : } > > Oh man, that's just sick... Partially because it's unnecessari

Re: [PHP] Control Structure problem

2003-09-16 Thread Eugene Lee
On Wed, Sep 17, 2003 at 01:29:26PM +1000, Tom Rogers wrote: : Wednesday, September 17, 2003, 11:47:45 AM, Eugene Lee wrote: : : EL> The switch statement doesn't do an equivalency test, does it? [...] : EL> it doesn't do: : : EL> if (($var === 'TEST-1') || : EL>($var === 'TEST-

Re: [PHP] Control Structure problem

2003-09-16 Thread Curt Zirzow
* Thus wrote Eugene Lee ([EMAIL PROTECTED]): > On Wed, Sep 17, 2003 at 12:49:03AM +, Curt Zirzow wrote: > The switch statement doesn't do an equivalency test, does it? So while > this switch statement can be rewritten as: > > if (($var == 'TEST-1') || ($var == 'TEST-1') || ($var == 'TE

Re: [PHP] Control Structure problem

2003-09-16 Thread Eugene Lee
On Wed, Sep 17, 2003 at 12:49:03AM +, Curt Zirzow wrote: : : switch ($var) { : case 'TEST-1': case 'TEST-2': case 'TEST-2': : do something : } The switch statement doesn't do an equivalency test, does it? So while this switch statement can be rewritten as: if (($var =

Re: [PHP] Control Structure problem

2003-09-16 Thread Luke Skywalker
gt; Sent: Wednesday, September 17, 2003 10:51 AM Subject: RE: [PHP] Control Structure problem > are you thinking of "default:" ? > > -Original Message- > From: Luke Skywalker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, 17 September 2003 10:51 AM > To: [EMAIL PROTECT

RE: [PHP] Control Structure problem

2003-09-16 Thread Martin Towell
are you thinking of "default:" ? -Original Message- From: Luke Skywalker [mailto:[EMAIL PROTECTED] Sent: Wednesday, 17 September 2003 10:51 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Control Structure problem yeah, i really like using cases they work well and especially if y

Re: [PHP] Control Structure problem

2003-09-16 Thread Luke Skywalker
- From: "Curt Zirzow" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 17, 2003 10:49 AM Subject: Re: [PHP] Control Structure problem > * Thus wrote Chris W. Parker ([EMAIL PROTECTED]): > > Dan J. Rychlik <mailto:[EMAIL PROTECTED]> > >

Re: [PHP] Control Structure problem

2003-09-16 Thread Curt Zirzow
* Thus wrote Chris W. Parker ([EMAIL PROTECTED]): > Dan J. Rychlik > on Tuesday, September 16, 2003 5:12 PM said: > > > Thank you guys. I truly know the level of expertise on this mailing > > list, and I know that it proves invaluable. > > > p.p.s. I totally thin

Re: [PHP] Control Structure problem

2003-09-16 Thread Luke Skywalker
CTED]>; "Luke Skywalker" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, September 17, 2003 10:18 AM Subject: RE: [PHP] Control Structure problem Dan J. Rychlik <mailto:[EMAIL PROTECTED]> on Tuesday, September 16, 2003 5:12 PM said: > Thank yo

RE: [PHP] Control Structure problem

2003-09-16 Thread Chris W. Parker
Dan J. Rychlik on Tuesday, September 16, 2003 5:12 PM said: > Thank you guys. I truly know the level of expertise on this mailing > list, and I know that it proves invaluable. If by "I truly know the level of expertise on this mailing list" you meant "I truly don'

Re: [PHP] Control Structure problem

2003-09-16 Thread Luke Skywalker
ROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, September 17, 2003 10:12 AM Subject: Re: [PHP] Control Structure problem > Thank you guys. I truly know the level of expertise on this mailing list, > and I know that it proves invaluable. > > Thank you again. > -Dan >

Re: [PHP] Control Structure problem

2003-09-16 Thread Dan J. Rychlik
Thank you guys. I truly know the level of expertise on this mailing list, and I know that it proves invaluable. Thank you again. -Dan - Original Message - From: "Luke Skywalker" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, September 16, 2003 7:0

Re: [PHP] Control Structure problem

2003-09-16 Thread Luke Skywalker
try if ( $var == "TEST ONE" || $var == "TEST TWO" || $var == "TEST THREE") { do something; } luke - Original Message - From: "Dan J. Rychlik" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 17, 2003 9:53 AM Subject: [PHP] Control Structure problem This does

RE: [PHP] Control Structure problem

2003-09-16 Thread Jennifer Goodie
> This doesnt work as expected. > > if ( $var === "TEST ONE" || "TEST TWO" || "TEST THREE") { > > do something; > > } > > It returns true on all strings. Ive tried using the or operator > and the == but these fail as well. Any Ideas? It behaves exactly as expected. Try checking the manual

Re: [PHP] control structure question

2002-07-25 Thread Miguel Cruz
On Tue, 23 Jul 2002, Javier Montserat wrote: > So refering back, i re-wrote the original example using the switch syntax... > > switch (true) { > case doStep1(): > case doStep2(): > case doStep3(): > error(); > break; > default: > valid(); > } > > Each case expressions is evaluated, until

Re: [PHP] control structure question

2002-07-23 Thread Javier Montserat
So refering back, i re-wrote the original example using the switch syntax... switch (true) { case doStep1(): case doStep2(): case doStep3(): error(); break; default: valid(); } Each case expressions is evaluated, until one of them evaluates to a value equal (==) to the switch expression (

Re: [PHP] control structure question

2002-07-23 Thread Martin Clifford
For steps and sequences, I always use switches. Most commonly associated with the "action" variable, it would look like this: switch($action) { default: // what to show if no variable exists, or is set to a value // that is not acceptable below break; case "add_file":

RE: [PHP] Control Structure Problem

2001-07-22 Thread Jeff Oien
I forgot to say I deleted tabs so that the width might fit in a typical mail reader. Jeff Oien > This code assigns rooms to kids signing up for Sunday school > at a very large church. Each subsequent registration is put into > the next room on the list. It looks up in the MySQL database > the r