Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. //SOF - this is just a refference point.
  3. //lets assign some values to begin with, notice that you can assign a variable to a variable,
  4. //this meens that same value wil be held in both.
  5. $a = 1;
  6. $b = 2;
  7. $c = 4;
  8. $e = $c;
  9. $start = 'here';
  10. $end = 'there';
  11. $distance = '10';
  12.  
  13. //ok, new we have some values assigned we can start playing with them :
  14.  
  15. $result = (($a * $b) / (($c - $b) + 94));
  16.  
  17. //in the above line you can see that, just as in mathematics, parenthesis () can be used to
  18. //force the order that parts of a complex calculation are performed.
  19.  
  20. //now well look at doing some comparison.  To do a compare you need to use whats called a
  21. //conditional statement.  Either an if, a for or a while.  as Both for and while are
  22. //actualy loops that perform conditional checks well stick with an if first of all.
  23. //Have a look at the if and how it's built, but don't worry if it doesn't make sense,
  24. //we'll be coming back to them later, our focus just now is what's between the ().
  25. if ($result >= $e){
  26.     $status = 'Is greater than or equal to';
  27. }
  28. elseif($result <= $e){
  29.     $status = 'Is less than or equal to';
  30. }
  31. else{
  32.     $status = 'Mathatmatical impossibility encountered. Cool.';
  33. }
  34.  
  35. //next were going to play with a while loop, again, don't worry if you don't get the
  36. //while looping thing, were only paying for the operators just now, so feel free to
  37. //leave the loops at the side of your plate if you don't like them.
  38.  
  39. $travels = ''; //we can assign nothing to a variable as well as a value
  40. while ($distance >= 1){
  41.     $travels .= "$start is not $end, there is still $distance more miles to go.<br>";
  42. //what's that? An operator I didn't tell you about? Sneeky huh? We'll get to it, don't worry
  43. // I was just making sure your paying attention.
  44.     $distance--;
  45. }
  46. if ($distance == 0){
  47.     $travels .= "$start is $end, because there is $distance more miles to go.<br>";
  48. }
  49.  
  50. //EOF - just another refference point
  51. ?>