Newbie question on ELSE statement
Posted: Fri Oct 19, 2007 7:34 pm
feyd | Please use
My present problem is that the ELSE statements at the end of end of the sample does not work (i.e. else{$baseShippingCost = 0;}), it seems to be ignored if the expression evaluates to FALSE. Everything else seems to work correctly.
I would appreciate any help I can get on this !
THANK YOU!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Can someone please look at my code and tell me what I am doing wrong? I am fairly new at programming (a fascinating science!), but on this I am sure everything looks correct, but for some reason, it does not seem to work like it supposed to. First, let me give you an example of the code that I think should be working right, and then I will explain what is going on. Keep in mind I am new at this stuff and would appreciate any good advice I can get from you experts.
Here is a sample of the code I am dealing with:Code: Select all
$exclude_gnd=1; if(strpos($methodName, '2nd') !== false and $exclude_gnd!==0){ if($twoDayZone != '-'){ $baseShippingCost = us_get_cost_for_lbs_and_zone('ups_commus48_2da', $evalWeight, $twoDayZone); $shipDiscount = $shippingDiscounts['second']; }/*elseif($twoDayZone = '-'){$baseShippingCost = 0;}*/ else {$baseShippingCost = 0;} }My present problem is that the ELSE statements at the end of end of the sample does not work (i.e. else{$baseShippingCost = 0;}), it seems to be ignored if the expression evaluates to FALSE. Everything else seems to work correctly.
I would appreciate any help I can get on this !
THANK YOU!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]