Created
September 12, 2013 04:02
-
-
Save tylersamples/6532908 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Multiple | |
| Line | |
| Comment | |
| */ | |
| /* Generally you see it | |
| * with the *'s | |
| * when it is dictating a copyright header | |
| * or when it's extremely long | |
| * just so you can follow how long it is | |
| */ | |
| // in-line comment, single-line comment | |
| // generally used like so: | |
| $myVar = 0; // DO NOT CHANGE, $myVar must remain 0 | |
| $myArray = Array("Value", "Value 1"); // two objects | |
| echo $myArray[0]; // output: "Value" | |
| //NOTICE: how the accessor for array begins at 0 not 1. If you have 16 elements in an array your last element is at 15 | |
| echo $myArray[1]; // output "Value 1" | |
| if($myVar!=0) | |
| { | |
| echo "Who the hell changed myVar? " . $myVar; | |
| // NOTE: the period between the string, i.e. "".$variable is to concatenate, aka combine | |
| } else | |
| { | |
| echo "Sweet, no one change my variable"; | |
| } | |
| // functions may not seem important at this time but they are: syntax is function function_name($paramater0, $paramater1, etc....) {} | |
| function addOne($n) | |
| { | |
| return $n+1; | |
| } | |
| echo addOne(2); // output: 3 | |
| for($i=0; $i<10; $i++) | |
| { | |
| echo "Hello from the number: " . $i . ", Up next is the number: " addOne($i); | |
| } | |
| $counter = 0; | |
| while(true) | |
| { | |
| if($counter==132) | |
| break; // exits the loop | |
| $counter++; // or alternatively, $counter+=1; or $counter = addOne($counter); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment