Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - problem with conditional switch -


the example below extráct http://php.net/manual/de/control-structures.switch.php

<?php $totaltime = 0; switch ($totaltime) {      case ($totaltime < 1):         echo "that fast!";         break;      case ($totaltime > 1):         echo "not fast!";         break;      case ($totaltime > 10):         echo "that's slooooow";         break; }  ?> 

i expected result "that fast." actual result "not fast!". great if 1 can explain me why?

but if add case, case 0: echo "that super fast!". echoing properly. i.e "that super fast!". please me how use conditional switch statement.

edit:-

thanks responses. able overcome above problem modifyong switch($totaltime) switch(1)

case ($totaltime < 1): means 1 php (that equation returns true)

case ($totaltime > 1): means 0 php (that equation returns false)

since $totaltime 0, output

in other words php compares $totaltime result of comparisons.

edit regarding edit in op:

you need rid of switch()-statement. use compare against different values , not use additional expressions it.

i mean wrong with

<?php $totaltime = 0;  if ($totaltime < 1) {     echo "that fast!"; } else if ($totaltime > 10) {     echo "that's slooooow"; } else if ($totaltime > 1) {     echo "not fast!"; }  ?> 

edit: please note switched last 2 if-statements make work.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -