Learning PHP and MySQL
Wednesday, July 19, 2006
Example 03-22 PHP mathematical function usage
<?php>
$sunny_days=300;
$Margaritaville_sunny_days_ratio=$sunny_days/365;
echo $Margaritaville_sunny_days_ratio;
?>
Example 03-23 Using autoincrement to add to a variable
<?php
$counter=1;
$counter++;
echo $counter
?>
Produces:
2
Example 03-24 Using the autodecrement operator
<?php
$counter=1;
$counter--;
echo $counter
?>
Produces:
0
Example 03-25 Using pre- and post-increment
<?php
$test=1;
echo "Preincrement: ".(++$test);
echo "<BR>";
echo "Value afterwords: ".$test;
echo "<BR>";
$test=1;
echo "Postincrement: ".($test++);
echo "<BR>";
echo "Value afterwords: ".$test;
?>
Produces:
Preincrement: 2
Value afterwords: 2
Postincrement: 1
Value afterwords: 2
Chapter 3 Code • (26) Comments • (2) Trackbacks • Permalink
Example 3-21 Echoing the line and file predefined constants for a script called predefined_constants
<?php
echo "Executing line ". __LINE__ . " of PHP script " . __FILE__ . '.';
?>
Returns:
Executing line 2 of PHP script /home/www/html/oreilly/ch3/predefined_constants.php.
Chapter 3 Code • (0) Comments • (1067) Trackbacks • Permalink
Statistics
This page has been viewed 407266 times
Page rendered in 0.1960 seconds
Total Entries: 224
Total Comments: 16
Total Trackbacks: 307338
Most Recent Entry: 09/27/2006 12:39 pm
Most Recent Comment on: 10/26/2007 10:00 am
Total Members: 2
Total Logged in members: 0
Total guests: 10
Total anonymous users: 0
Most Recent Visitor on: 05/19/2012 05:09 am
The most visitors ever was 1103 on 11/20/2007 12:50 pm
