Operating on variables : Variables « Language Basics « PHP






Operating on variables

 
<?php
$price = 3.95;
$tax_rate = 0.08;
$tax_amount = $price * $tax_rate;
$total_cost = $price + $tax_amount;

$username = 'james';
$domain = '@example.com';
$email_address = $username . $domain;

print 'The tax is ' . $tax_amount;
print "\n"; // this prints a linebreak
print 'The total cost is ' .$total_cost;
print "\n"; // this prints a linebreak
print $email_address;
?>
  
  








Related examples in the same category

1.PHP Variable Examples
2.PHP Superglobal Arrays
3.PHP 5 variable functionality.
4.A properly set-up PHP variable
5.Automatic Type Conversion
6.Calculate the variable name for simpler variables and use that name to access the value of that variable.
7.valid statements
8.Numbers
9.Numeric Data Types
10.Valid and invalid variable names