Skip to content

Instantly share code, notes, and snippets.

@tylersamples
Created September 12, 2013 04:02
Show Gist options
  • Select an option

  • Save tylersamples/6532908 to your computer and use it in GitHub Desktop.

Select an option

Save tylersamples/6532908 to your computer and use it in GitHub Desktop.
<?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