Escolar Documentos
Profissional Documentos
Cultura Documentos
(phptags.php)
<?php
echo "<P>This is a test using the first tag type.</P>";
?>
<?
echo "<P>This is a test using the second tag type.</P>";
?>
<script language="php">
echo "<P>This is a test using the third tag type.</P>";
</script>
(firstscript.php)
<HTML>
<HEAD>
<TITLE>My First PHP Script</TITLE>
</HEAD>
<BODY>
<?
echo "<P><em>Hello World! I'm using PHP!</em></P>";
?>
</BODY>
</HTML>
(errorscript-a.php)
<HTML>
<HEAD>
<TITLE>Trying For Another Error</TITLE>
</HEAD>
<BODY>
<?
echo "<P>I am trying to produce an error</P>"
echo "<P>Was I successful?</p>";
?>
</BODY>
</HTML>
(errorscript-b.php)
<HTML>
<HEAD>
<TITLE>Trying For Another Error</TITLE>
</HEAD>
<BODY>
<?
echo "<P>I am trying to produce an error</P>";
echo "<P>Was I successful?</p>";
?>
</BODY>
</HTML>
(errorscript2-a.php)
<HTML>
<HEAD>
<TITLE>Trying For Another Error</TITLE>
</HEAD>
<BODY>
<?
echo "<P>I think this is really "cool"!</p>";
?>
</BODY>
</HTML>
(errorscript2-b.php)
<HTML>
<HEAD>
<TITLE>Trying For Another Error</TITLE>
</HEAD>
<BODY>
<?
echo "<P>I think this is really \"cool\"!</p>";
?>
</BODY>
</HTML>
(comments.php)
<HTML>
<HEAD>
<TITLE>Code Comments</TITLE>
</HEAD>
<BODY>
<?
?>
(printvarscript.php)
<HTML>
<HEAD>
<TITLE>Printing Variables</TITLE>
</HEAD>
<BODY>
<?
$intVar = "9554215464";
$floatVar = "1542.2232235";
$stringVar = "This is a string.";
(phpinfo.php)
<? phpinfo(); ?>
(constants.php)
<?
define("MYCONSTANT","This is a test of defining constants.");
echo MYCONSTANT;
?>
(constants2.php)
<?
echo "<br>This file is ".__FILE__;
<?
$origVar = 100;
echo "<P>Original value is $origVar</p>";
$origVar += 25;
echo "<P>Added a value, now it's $origVar</p>";
$origVar -= 12;
echo "<P>Subtracted a value, now it's $origVar</p>";
(arithmeticscript.php)
<HTML>
<HEAD>
<TITLE>Using Arithmetic Operators</TITLE>
</HEAD>
<BODY>
<?
$a = 85;
$b = 24;
echo "<P>Original value of \$a is $a and \$b is $b</p>";
$c = $a + $b;
echo "<P>Added \$a and \$b and got $c</p>";
$c = $a - $b;
echo "<P>Subtracted \$b from \$a and got $c</p>";
$c = $a * $b;
echo "<P>Multiplied \$a and \$b and got $c</p>";
$c = $a / $b;
echo "<P>Divided \$a by \$b and got $c</p>";
$c = $a % $b;
echo "<P>The modulus of \$a and \$b is $c</p>";
?>
</BODY>
</HTML>
comparisonscript.php
<HTML>
<HEAD>
<TITLE>Using Comparison Operators</TITLE>
</HEAD>
<BODY>
<?
$a = 21;
$b = 15;
echo "<P>Original value of \$a is $a and \$b is $b</p>";
if ($a == $b) {
echo "<P>TEST 1: \$a equals \$b</p>";
} else {
echo "<P>TEST 1: \$a is not equal to \$b</p>";
}
if ($a != $b) {
echo "<P>TEST 2: \$a is not equal to \$b</p>";
} else {
echo "<P>TEST 2: \$a is equal to \$b</p>";
}
logicalscript.php
<HTML>
<HEAD>
<TITLE>Using Logical Operators</TITLE>
</HEAD>
<BODY>
<?
$degrees = "95";
$hot = "yes";
?>
</BODY>
</HTML>