Skip to content

Writing a Math Function #6

@github-learning-lab

Description

@github-learning-lab

Functions

Functions are pre-built commands in PHP that do some of the hard work for you. You can also write your own custom function. The function we will write will calculate tax, but first let's go over using math in PHP

Using Math

By using math symbols you can add(+), subtract(-), multiply(*) or divide(/) variables. Add this to the bottom of your php tags:

$amount=800;
$taxRate=0.0825;
$addedTax= $amount*$taxRate;  //amount = 800, tax = .0825
echo $addedTax;

Refresh the page, and leave a comment with the value of $addedTax to continue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions