Sunday, September 05th, 2010 Welcome Guest! - Register    
Sign In
Forget your password?
Username:  
Password:   
Stay Logged in for:

Donations to date: $62.50
Support This Site Today!

Top 3 Active Posters
Ntsmarkv
SetoTK
mcstec

Latest Forum Posts
dbconfig video guide...

kasl products on sale!...

forum topic...

webhost 2.0...

download page demo's d...

edit post in forum...

portal & users...

webhost 2 language sys...

cosmetic bug : no aft...

forum subtopics...


Forums
Forums
On Sale!
Downloads
Bookmarks
Bookmarks
Contact Us
Contact Us

Sale is Over

The sale in the download's section is now over.


Posted by ~Ntsmarkv on Monday, August 31st, 2010 10:03 PM MST

PHP - Comments / Math


PHP can do all kinds of great things. You could almost live without real programs because of the things you could do through a web browser. One of the things PHP can do is math. Although I can not show you because it is protected, I created a program for my "real" job that calculates the weight of metal, the price of the weight times the quantity, etc.

---------------------------------------

<?php

// this is a comment line. You can tell because it starts with two forward slashes

// here is another line of comments

# this is also a comment line. It starts with a hash mark
# here is another
# here is another

/*
* this is a multiple line comment
* all of this text is commented out
*
* this type is best for multiple lines, but that is my opinion
*/

// this defined the variable that will be used in the title tags
$title 'hello world!'?>

<html>
<head>
<title><?php echo $title?></title>
</head>

<body>

Here is a little math:

<?php // start the PHP tags - telling the server to parse the code

// assign the value of 4 to the $number1 variable
$number1 '4';
// assign the value of 6 to the $number2 variable
$number2 '6';

// add up $number1 (4) and $number2 (6), the total is assigned to
// the $sum variable
$sum $number1 $number2;

// print the $sum (10) to the browser
echo "The sum of $number1 + $number2 is $sum";

// add a couple of line breaks to the page
echo "<br /><br />";

// you can also use this code to print to a browser:
print "The sum of $number1 + $number2 is $sum";

// close the php tags:
?>

</body>

</html>


---------------------------------------

If you study the top 13 or so lines of that code, you can see what I have done for comments. Comments are notes that a programmer can write to describe what is going on in the code. The good thing about comments is when the server parses the code, it will ignore anything that is commented out, thus making it invisible to everything except the programmer(s).

If you read the PHP Introduction tutorial, you saw how to assign variables. You can assign strings and integers to variables. Strings are text and numbers and characters, but integers are just
numbers.


If you have two variables that are defined by numbers, you can add them together or do any other mathematical operations.

For example, you saw that $number1 equals 4 and that $number2 equals 6. When they were added together, they equaled 10 which was assigned the the variable $sum.

The source code for this article is available at http://www.kasl.info/source



This page has been accessed 2,268 times     


Search Forums

Articles
PHP - Introduction..

PHP - Comments / Math..

PHP - Work With MySql..

PHP - Login/Logout Scri..

PHP - Track Traffic..

PHP - Who's Online..


Site Stats
Since July 23, 2005:
1,075,804 hits
783,208 unique visitors
Today's Info:
227 hits
74 unique visitors
More Traffic Stats

Who's Online: Active
Users: 0
Guests: 75
Truncate Online Users:

KASL Members:
Currently 2,539
Newest member: Gilues
Forum Stats:
There are 9 categories
There are 16 topics
There are 67 posts
Page Load Time
Page loaded in 0.030 secs.