Source code for:
challenge1_1.php
<html>
<head>
<title>Q7310 Challenge1.1</title>
</head>
<BODY bgcolor="000000" link="#FFFF00" vlink="#FFFF00" alink="#00FF00" text="#ececec">
<h1 align="center">
Program #1 <br> Just the Basics of PHP Data Types
</h1>
<DIV align="center">
<FONT face="arial, helvetica, sans-serif" size=2 color="ececec">
<TABLE width="90%" border=1 cellpadding=10 cellspacing=0>
<TR width="20%">
<td>
<FONT color="yellow">
<b>EXAMPLE DATA </b>
</FONT>
</td>
<td>
<FONT color="yellow">
Displayed "value" from variable(s) <b> $testing </b><br>
<b>DATA TYPE </b> using GETTYPE function
</FONT>
</td>
</TR>
<TR>
<td>
Data #1
</TD>
<TD>
<?php
$testing; //Declare without assigning
print $testing;
print "<br>";
print gettype($testing); // NULL
?>
</TD>
</TR>
<TR>
<TD>
Data #2
</TD>
<TD>
<?php
$testing=5;
print $testing;
print "<br>";
print gettype($testing); // INTEGER
?>
</TD>
</TR>
<TR>
<TD>
Data #3
</TD>
<TD>
<?php
$testing="five";
print $testing;
print "<br>";
print gettype($testing); // STRING
?>
</TD>
</TR>
<TR>
<TD>
Data #4
</TD>
<TD>
<?php
$testing=5.50;
print $testing;
print "<br>";
print gettype($testing); // DOUBLE
?>
</TD>
</TR>
<TR>
<TD>
Data #5
</TD>
<TD>
<?php
$testing=true;
print $testing;
print "<br>";
echo " boolean value = TRUE";
print "<br>";
print gettype($testing); // BOOLEAN TRUE
?>
</TD>
</TR>
<TR>
<TD>
Data #6
</TD>
<TD>
<?php
$testing=false;
print $testing;
print "<br>";
echo "boolean value = FALSE";
print "<br>";
print gettype($testing); // BOOLEAN false
?>
</TD>
</TR>
<TR>
<TD>
Data #7
</TD>
<TD>
<?php
$testing=false;
print $testing;
print "<br>";
settype($testing, 'integer'); // Change to Integer
echo " FALSE changed to INTEGER";
print "<br>";
print $testing; print "<br>";
print gettype($testing); // was BOOLEAN false
?>
</TD>
</TR>
<TR>
<TD>
Data #8
</TD>
<TD>
<?php
$testing=true;
print $testing;
print "<br>";
settype($testing, 'string'); //Change to STRING
echo " boolean value=TRUE changed to STRING";
print "<br>";
print $testing;
print "<br>";
print gettype($testing); // was BOOLEAN true
?>
</TD>
</TR>
<TR>
<TD>
Data #9
</TD>
<TD>
<?php
$testing = array("This", "is", "a", "1row X 5columns", "array");
print $testing[0]; echo " ";
print $testing[1]; echo " ";
print $testing[2]; echo " ";
print $testing[3]; echo " ";
print $testing[4]; echo "!";
print "<br>";
print gettype($testing); // ARRAY
echo "The number of elements = ";
print count($testing);
?>
</TD>
</TR>
<TR>
<TD>
Data #10
</TD>
<TD>
<?php
class first_class
{
var $name;
function sayHello()
{
print "This is an object using a function called sayHello";
}
}
$testing = new first_class();
$testing ->sayHello();
print "<br>";
print gettype($testing);
// ========================================================
// define class 'first_class'
// define variable '$name'
// define function 'sayHello'
// define action
// define new class
// define action for variable -> use function
// ========================================================
?>
</TD>
</TR>
<TR>
<TD>
</TD>
<TD>
SOURCE CODE: Click
<A HREF="http://rrchubbard.org/php/q7310/source1_1.php" target="_blank">
HERE </A>
</TD>
</TR>
</TABLE>
</FONT>
</DIV>
[<A href="top" target="_self">Top</A>]
<BR>
Last Updated
<I>:
<!-- #BeginDate format:fcAm1m -->Friday, September 17, 2004 21:39<!-- #EndDate -->
</I>
<P>
<FONT face="Arial, Helvetica, sans-serif" size="1">
(c) 2004 Robin Y. Mabry Hubbard <A href="mailto:4ascii@marz.com">4ascii@marz.com</A>
</FONT>
</P>
</body>
</html>
|