All pastes #556128 Raw Edit

Untitled

public php v1 · immutable
·published 2007-06-10 13:05 UTC
rendered paste body
<TITLE>Oliver's php Playpen!</title><H1> Hey doug:</H1>NOTE: echo "<br />" works as a line break<BR><BR><H2> Variables: Creation and Manipulation</H2><H3>Creation:</H3><?php/* The following is a test of all the basic syntax so as to familiarise myself with naming conventions, required layouts and so forth.... ignore that man behind the curtain*///Simple variable creation$var_string = 'This ($var_string) is a string';echo $var_string;?><BR><?php$var_num = 1800;print $var_num;?><BR><BR><H3>Concatenation:</H3><?php//Variable manipulation$var_string2 = ", and i've added punctuation so I have to use double quotes.";echo $var_string . $var_string2;?><BR><BR><H3>Stringlentgth Function</H3>String length of the above two strings:<?phpecho strlen($var_string) + strlen($var_string2)?><BR><BR><H3>String-Position Function</H3>In the first string, 'is a' occurs at position<?phpecho strpos($var_string,"is a");?><BR><BR><H3>Conditional Statements</H3><?php$d=date("D");if ($d=="Mon")    echo "Haha, it's monday and you're working but i dont have uni today!";else    echo "Oh well, at least it's not monday";?><BR><BR><H3>Switch</H3><?phpprint "Computer, think of a random integer between 1 and 5";$x=rand(0,5);Switch ($x){case 1:    echo "Was it 1?";    echo "Yes";    break;case 2:    echo "Was it 2?";    echo "Yes";    break;case 3:    echo "Was it 3?";    echo "Yes";    break;case 4:    echo "Was it 4?";    echo "Yes";    break;case 5:    echo "Was it 5?";    echo "Yes";    break;default:    echo "You cheated!"; //Yes, im aware that it is my fault that it cheated (ie i assigned it a int between 0 and 5)//but i wanted the possibility of a default statement}?><BR><BR><BR><H3> Heredoc</H3><?php$heredoc = <<<EOHBThis here is a large block of text, into which i can put punctuation, "both 'types' of quotes", also have variables appear(such as the integer the computer chose (it was '$x' if you dont remember) and so forthbut it doesn't line break when i doEOHB;echo $heredoc?><BR><BR><H3> Arrays </H3>Basic Numerical Type: <BR><?php$array = array("30","12","Last value");echo $array[1] . ", " . $array[2] . ", " . $array[0];?><BR><BR>Associative Type: <BR><?php$ass_array = array("Doug"=>1, "Others"=>2, "Oliver"=>3);echo "Doug is at position number " . $ass_array[Doug] . " in the hierachy of this company." ;//i'll do multidimensional arrays later?><BR><BR><H3>Simple looping statements</H3><?phpfor ($i=1; $i<=5; $i++){ echo "No TV and no beer make Homer go crazy<br />";}?>