Online
 
Friday, 09 January 2009
 
 
More article:
Related Content:

Variable Manipulation PHP
 

Variable Manipulation

Now that you have been introduced to the basic PHP data types, let's explore how these data types can be manipulated to perform calculations and more using PHP. As you would expect, PHP supports all the basic mathematical operations of any programming language, including addition and multiplication as well as a wide range of trigonometric and logarithmic functions. Beyond mathematical manipulations, PHP supports an even greater amount of string manipulation functions. This chapter will cover only the more fundamental variable manipulations used in both strings and mathematics.

Performing mathematical operations in PHP is a fairly intuitive task. PHP supports all the common mathematical standards for operator precedence, groupings, and so on for both integers and floating-point numbers.

Simple Mathematics with PHP Variables
<?php



$answer = 5 + 4; /* $answer now equals 9 */

$answer = $answer - 5; /* $answer now equals 4 */

$answer = $answer / 2; /* $answer now equals 2 */

$answer = 1/3; /* $answer is now 0.333333 */

$answer = ((5 + 4)*2) % 7; /* $answer now equals 4 */



?>

Tags: Add more tags...,
This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment. Tags: Simple PHP, Pear, Easy PHP, PHP Tutorial, PHP MySQL, XSLT, Sap Tutorial, CSS Tutorial, XSL FO Java, SQL Tutorial.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 4000
 Notify me of follow-up comments
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage
Enter what you see:

No comment posted

Natural 345
Statistic


Last Post

 
Top! Top!