PHP Tutorial-Alt Code Documentation
Documentation of PHP Tutorial-Alt Code by Doxygen
 All Files Functions Variables Pages
php_barebones_alt.php File Reference

php_barebones_alt.php is a bare-bones PHP tutorial. More...

Functions

 SetSessionVisits ()
 SetSessionVisits() sets a visits variable for $_SESSION. More...
 
 TestEquality ($input1, $input2)
 TestEquality($input1, $input2) tests two variables for equality (==). More...
 
 TestIdentity ($input1, $input2)
 TestIdentity($input1, $input2) tests two variable for identity (===). More...
 
 ProcessFavorite ()
 ProcessFavorite() processes a favorite color and/or number supplied by the user. More...
 
 ListForStarNames ($array)
 ListForStarNames($array) displays a list of star names from an indexed array. More...
 
 SortStars ($array)
 SortStars($array) sorts in ascending order a list of star names from an indexed array. More...
 
 RsortStars ($array)
 RsortStars($array) sorts in descending (reverse) order a list of star names from an indexed array. More...
 
 ListStarClasses ($array)
 ListStarClasses($array) displays a list of star classes and examples from an associative array. More...
 
 AsortStars ($array)
 AsortStars($array) sorts in ascending order by value a list of star classes and examples from an associative array. More...
 
 ArsortStars ($array)
 ArsortStars($array) sorts in descending (reverse) order by value a list of star classes and examples from an associative array. More...
 
 KsortStars ($array)
 KsortStars($array) sorts in ascending order by key a list of star classes and examples from an associative array. More...
 
 KrsortStars ($array)
 KrsortStars($array) sorts in descending (reverse) order by key a list of star classes and examples from an associative array. More...
 
 ListWhileStarNames ($array)
 ListWhileStarNames($array) displays a list of star names from an indexed array. More...
 
 ListDoStarNames ($array)
 ListDoStarNames($array) displays a list of star names from an indexed array. More...
 
 ProcessInput ($input1, $input2)
 ProcessInput($input1, $input2) processes two inputs supplied by the user. More...
 
 PreprocessInput ()
 PreprocessInput() pre-processes two inputs supplied by the user. More...
 

Variables

 $expireCookie = time()+60*60*24
 
 $a = 1
 
 $b = 2
 
 $c = $a + $b
 
 $d = "Done!"
 
 $e = "This is a string"
 
 $f = 5
 
 $g = "5"
 
 $color = "none"
 
 $num = 0
 
 $starNames = array("Proxima Centauri", "Arcturus", "Sol", "Fomalhaut", "Deneb", "Rigel", "Zeta Ophiuchi")
 
 $tempStarNames = $starNames
 
 $starClassExamples = array("M"=>"Proxima Centauri", "K"=>"Arcturus", "G"=>"Sol", "F"=>"Fomalhaut", "A"=>"Deneb", "B"=>"Rigel", "O"=>"Zeta Ophiuchi")
 
 $stellarDwarves
 

Detailed Description

php_barebones_alt.php is a bare-bones PHP tutorial for HMTL pages, using PHP code mixed in with the HMTL source code.

Function Documentation

ArsortStars (   $array)

AsortStars($array) sorts in descending (reverse) order by value a list of star classes and examples from an associative array and then displays (echoes) them.

Parameters
$arrayArray to be arsorted and displayed.
AsortStars (   $array)

AsortStars($array) sorts in ascending order by value a list of star classes and examples from an associative array and then displays (echoes) them.

Parameters
$arrayArray to be asorted and displayed.
KrsortStars (   $array)

KrsortStars($array) sorts in descending (reverse) order by key a list of star classes and examples from an associative array and then displays (echoes) them.

Parameters
$arrayArray to be krsorted and displayed.
KsortStars (   $array)

KsortStars($array) sorts in ascending order by key a list of star classes and examples from an associative array and then displays (echoes) them.

Parameters
$arrayArray to be ksorted and displayed.
ListDoStarNames (   $array)

ListDoStarNames($array) displays (echoes to the HTML output) a list of star names from an indexed array, using a do ... while loop.

Parameters
$arrayArray to be displayed.
ListForStarNames (   $array)

ListForStarNames($array) displays (echoes to the HTML output) a list of star names from an indexed array, using a for loop.

Parameters
$arrayArray to be displayed.
ListStarClasses (   $array)

ListStarClasses($array) displays a list of star classes and examples from an associative array, using a foreach loop.

Parameters
$arrayArray to be displayed.
ListWhileStarNames (   $array)

ListWhileStarNames($array) displays (echoes to the HTML output) a list of star names from an indexed array, using a while loop.

Parameters
$arrayArray to be displayed.
PreprocessInput ( )

PreprocessInput() pre-processes two inputs supplied by the user and then calls ProcessInput() with the results of the pre-processing. This is done so that ProcessInput() is not cluttered with too much code and thus remains simple for the purposes of the function tutorial.

ProcessFavorite ( )

ProcessFavorite() processes a favorite color and/or number supplied by the user and echoes the result of the processing.

ProcessInput (   $input1,
  $input2 
)

ProcessInput($input1, $input2) processes two inputs supplied by the user and returns the result of the processing, either a message or a set of mathematical calculations. The function also demontrates uses of parameters and return values.

To keep things simple for the tutorial, the inputs are pre-processed by another function, PreprocessInput(), so that ProcessInput() is not cluttered with too much code.

Parameters
$input1The first input.
$input2The second input.
Returns
Returns a message if any input is not numeric. If both inputs are numeric, returns the results of: 1) adding the inputs together; 2) subtracting the second input from the first; 3) multiplying the inputs together.
RsortStars (   $array)

RsortStars($array) sorts in descending (reverse) order a list of star names from an indexed array and then displays (echoes) them.

Parameters
$arrayArray to be rsorted and displayed.
SetSessionVisits ( )

SetSessionVisits() sets a visits variable for $_SESSION. At the start of a session, visits is not set and the function sets it to 1. During a session, the function increments visits by one. The $_SESSION['visits'] variable thus can be used to track the number of times the user visits/reloads the page in a session.

For the purposes of this tutorial, the code could have been written in global scope (minus the function definition), but a function was used so that doxygen could better document it. Extra credit: Rewrite the code to have it work global scope. An Example: See PHP source code for one way to do this.

SortStars (   $array)

SortStars($array) sorts in ascending order a list of star names from an indexed array and then displays (echoes) them.

Parameters
$arrayArray to be sorted and displayed.
TestEquality (   $input1,
  $input2 
)

TestEquality($input1, $input2) tests two variable for equality (==) and echos the result. For the purposes of this tutorial, the code could have been written in global scope (minus the function definition and global variables statement), but a function was used so that doxygen could better document it. Extra credit: Rewrite the code to have it work global scope. An Example: See PHP source code for one way to do this.

Parameters
$input1The first input.
$input2The second input.
TestIdentity (   $input1,
  $input2 
)

TestIdentity($input1, $input2) tests two variable for identity (===) and echos the result. For the purposes of this tutorial, the code could have been written in global scope (minus the function definition and global variables statement), but a function was used so that doxygen could better document it. Extra credit: Rewrite the code to have it work global scope. An Example: See PHP source code for one way to do this.

Parameters
$input1The first input.
$input2The second input.

Variable Documentation

$a = 1

Variable for variables tutorial.

$b = 2

Variable for variables tutorial.

$c = $a + $b

Variable for variables tutorial.

$color = "none"

Favorite color for forms handling 1 tutorial.

$d = "Done!"

Variable for variables tutorial.

$e = "This is a string"

Variable for strings tutorial.

$expireCookie = time()+60*60*24

Cookie expires in 24 hours.

$f = 5

Variable with numeric value for equality vs. identity tutorial.

$g = "5"

Variable with string value for equality vs. identity tutorial.

$num = 0

Favorite number for forms handling 1 tutorial.

$starClassExamples = array("M"=>"Proxima Centauri", "K"=>"Arcturus", "G"=>"Sol", "F"=>"Fomalhaut", "A"=>"Deneb", "B"=>"Rigel", "O"=>"Zeta Ophiuchi")

An associative array of star class examples for the associative array tutorial.

$starNames = array("Proxima Centauri", "Arcturus", "Sol", "Fomalhaut", "Deneb", "Rigel", "Zeta Ophiuchi")

An indexed array of star names for the indexed array tutorial.

$stellarDwarves
Initial value:
= array(
"Red Dwarf Examples"=>array("Gliese 623 A", "Lalande 21185", "Proxima Centauri", "40 Eridani C"),
"White Dwarf Examples"=>array("IK Pegasi B", "Sirius B", "Van Maanen's Star", "40 Eridani B"),
"Brown Dwarf Examples"=>array( "OTS 44", "Teegarden's Star", "Teide 1", "WISE 1049-5319")
)

A multidimensional array for the multidimensional array tutorial.

$tempStarNames = $starNames

A temporary array used for sorting in the indexed array tutorial. This way, only the temporary array is sorted, not the original array.