ECHO INPUT
<?php
echo "Hello, this is a message. It is in quotes and uses the command --echo quoted message-- to call it up.";
?>
ECHO OUTPUT
Hello, this is a message. It is in quotes and uses the command --echo quoted message-- to call it up.
VAR INPUT
<?php
$txt = "Hello and Welcome to PHP on a HTML page. I am a variable and my name is (dollar sign)txt = quoted message; I use the command echo \$txt; to call me anytime you need me to appear on a page";
$var = "Name me anything but a number. Escape the dollar sign with a back slash before it just like when you escape quotes. \$";
echo $txt;
echo $var;
?>
VAR OUTPUT
Hello and Welcome to PHP on a HTML page. I am a variable and my name is (dollar sign)txt = quoted message; I use the command echo $txt; to call me anytime you need me to appear on a page.Escape the dollar sign with a back slash before it just like when you escape quotes. $
SALLY'S CODE INPUT
<?php
$webby = 'RCA MSNTV Plus';
$gd = 'GD Library';
$TT = 'TandemTables.com';
echo "<span style=\"font: xx-small; color: snow\">These graphics were<br /> hand coded with an<br />$webby<br /> utilizing the $gd at <br /> $TT";
?>
SALLY'S CODE OUTPUT
These graphics were
hand coded with an
RCA MSNTV Plus
utilizing the GD Library at
TandemTables.com
HEREDOC INPUT
<?php
$mystring = <<<EOT
Any text within the Heredoc commands will print out words. You can use "double" and 'single' quotes as well as \$variables--still need to escape the dollar sign. Also useful for dingbat ttf files that use quotes and other symbols to call them. Use for nested variables in gradtable art. Must have no spaces after the letters EOT (end of text);
EOT;
echo $mystring;
?>
NOTE: The total codes for the Heredoc is:
$generic = <<<EOT
words words words
EOT;
HEREDOC OUTPUT
Any text within the Heredoc commands will print out words. You can use "double" and 'single' quotes as well as $variables--still need to escape the dollar sign. Also useful for dingbat ttf files that use quotes and other symbols to call them. Use for nested tables in gradtable art. Must have no spaces after EOT codes;
ARRAY INPUT
<?php
$member_array[1]="Linda";
$member_array[2]="Sally";
$member_array[3]="Lila";
echo "The members are $member_array[1], $member_array[2], $member_array[3].";
?>
ARRAY OUTPUT
The members are Linda, Sally, Lila.
ARRAY INPUT
<?php
$member[Sally]=1;
$member[Lila]=2;
$member[Linda]=3;
echo "Sally is member $member[Sally]. Lila is member $member[Lila]. Linda is member $member[Linda]";
?>
ARRAY OUTPUT
Sally is member 1. Lila is member 2. Linda is member 3
WHILE LOOP INPUT
While (string relates to string/is true) do this.
++$x; is the same as writing $x = $x + 1;
<?php
$times = 5;
echo "<table border=\"1\" align=\"center\">";
$x = 0;
while ($x < $times)
{
echo "<tr><td>";
echo "Hello World";
++$x;
echo "</td></tr>";
}
echo "</table>";
?>
WHILE LOOP OUTPUT
Hello World
Hello World
Hello World
Hello World
Hello World
WHILE LOOP INPUT
Same loop as above using a gradtable.
<?php
$times = 5;
echo "<table border=\"0\" cellspacing=\"0\" align=\"center\">";
$x = 0;
while ($x < $times)
{
echo "<tr><td bgcolor=\"black\" gradcolor=\"red\" width=\"150\" height=\"20\" gradangle=\"90\"></td><td bgcolor=\"black\" gradcolor=\"red\" width=\"150\" height=\"20\" gradangle=\"-90\">";
++$x;
echo "</td></tr>";
}
echo "</table>";
?>
WHILE LOOP OUTPUT
WHILE LOOP INPUT
While (conditional statement {do this}
<?php
$item_price = 5;
$counter = 10;
echo "<table border=\"1\" align=\"center\">";
echo "<tr><<h>Quantity</th>";
echo "<th>Price</th></tr>";
while ( $counter <= 50 ) {
echo "<tr><td>";
echo $counter;
echo "</td><td>";
echo $item_price * $counter;
echo "</td></tr>";
$counter = $counter + 10;
}
echo "</table>";
?>
WHILE LOOP OUTPUT
QuantityPrice
1050
20100
30150
40200
50250
WHILE LOOP INPUT
Gradtable shows that second column is not a true calculator
<?php
$positive = 10;
$negative = -1;
echo "<table border=\"0\" cellspacing=\"0\" align=\"center\">";
echo "<tr><th>Positive</th>";
echo "<th>Negative</th></tr>";
while ($positive <= 200 ) {
echo "<tr><td bgcolor=\"black\" gradcolor=\"red\" width=\"150\" height=\"20\" gradangle=$positive>";
echo $positive;
echo "</td><td bgcolor=\"black\" gradcolor=\"red\" width=\"150\" height=\"20\" gradangle=$negative>";
echo $positive * $negative;
echo "</td></tr>"; $positive = $positive + 20;
}
echo "</table>";
?>
WHILE LOOP OUTPUT
PositiveNegative
10-10
30-30
50-50
70-70
90-90
110-110
130-130
150-150
170-170
190-190
WHILE LOOP INPUT
<HTML>
<BODY>
<?
$j=1;
echo ("<TABLE ALIGN=CENTER BORDER=1 CELLSPACING=1 CELLPADDING=5 >");
while ($j<=5) {
echo ("<TR>");
$k=1;
while ($k<=3) {
echo ("<TD> Line $j, Cell $k </TD>");
$k++;
}
echo("</TR>");
$j++;
}
echo ("</TABLE>");
?>
</BODY>
</HTML>
WHILE LOOP OUTPUT
Line 1, Cell 1 Line 1, Cell 2 Line 1, Cell 3
Line 2, Cell 1 Line 2, Cell 2 Line 2, Cell 3
Line 3, Cell 1 Line 3, Cell 2 Line 3, Cell 3
Line 4, Cell 1 Line 4, Cell 2 Line 4, Cell 3
Line 5, Cell 1 Line 5, Cell 2 Line 5, Cell 3
FOR LOOP INPUT
for ( initialize a counter; conditional statement; increment a counter){do this code; }
<?php
$item_price = 5;
echo "<table border=\"1\" align=\"center\">";
echo "<tr><th>Quantity</th>";
echo "<th>Price</th></tr>";
for ( $counter = 10; $counter <= 50; $counter += 10) {
echo "<tr><td>";
echo $counter;
echo "</td><td>";
echo $item_price * $counter;
echo "</td></tr>";
}
echo "</table>";
?>
FOR LOOP OUTPUT
QuantityPrice
1050
20100
30150
40200
50250
FOR LOOP IN IMAGE, DRAWS A LINE--INPUT
<?php
Header("Content-type: image/png");
$height = 300;
$width = 300;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 10,110,100);
$white = ImageColorAllocate($im, 255, 255, 255);
ImageLine($im, 0, 0, $width, $height, $white);
for($i=0;$i<=299;$i=$i+10) {
ImageLine($im, 0, $i, $width, $height, $white); }
ImagePNG($im);
imagedestroy($im);
?>
FOR LOOP IMAGE OUTPUT
SERVER INPUT
<html>
You are using
<?php
echo $_SERVER['HTTP_USER_AGENT']; ?>
<br /> and coming from
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
</html>
SERVER OUTPUT
You are using claudebot
and coming from 44.220.131.93
FUNCTION INPUT
<HTML>
<BODY>
<?
function createBoard ($lines, $cols)
{
$j=1;
echo ("<table align=center border=1 cellspacing=0>");
while ($j<=$lines) {
echo ("<tr>");
$k=1;
while ($k<=$cols) {
if (($j+$k)%2>0)
echo ("<td width=30 height=30 bgcolor=#000000></td>");
else
echo ("<td width=30 height=30 bgcolor=#ffffff></td>");
$k++;
}
echo("</TR>");
$j++;
}
echo ("</table><br /><br />");
}
createBoard(8,8);
createBoard(4,4);
?>
</body>
</html>
FUNCTION OUTPUT




FUNCTION INPUT AS ABOVE WITH GRADS
<HTML>
<BODY>
<?
function createGrads($lines, $cols)
{
$j=1;
echo ("<table align=center border=0 cellspacing=0 bgcolor=#000000>");
while ($j<=$lines) {
echo ("<tr>");
$k=1;
while ($k<=$cols) {
if (($j+$k)%2>0)
echo ("<td width=18 height=25 bgcolor=#000000 gradcolor=#cc9966 gradangle=90><td width=18 height=25 bgcolor=#000000 gradcolor=#cc9966 gradangle=-90></td>");
else
echo ("<td width=18 height=25 bgcolor=#000000 gradcolor=#0099cc gradangle=90><td width=15 height=25 bgcolor=#000000 gradcolor=#0099cc gradangle=-90></td>");
$k++;
}
echo("</TR>");
$j++;
}
echo ("</table><br /><br />");
}
createGrads(8,8);
createGrads(4,4);
?>
</body>
</html>
FUNCTION OUTPUT