A very simple PHP question ...

  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Posts: 86
  • Loc: Liverpool

Post 3+ Months Ago

I know the square root of zero about PHP, but I'm trying to edit an existing page on a website, and I wonder if someone could tell me if what I've worked out is correct please?

I need to test the current date (year) and if the year is 2010 or later, then change the value of the 'iTax' variable - this is to change the VAT amount in a legacy Shopping Cart app.

I've got this so far ...
Code: [ Select ]
/** My New Tax Variable **/

$whatYear = date('Y');

if $whatYear > 2009
{
$iTax = 17.5;
}
else
{
$iTax = 15;
}
  1. /** My New Tax Variable **/
  2. $whatYear = date('Y');
  3. if $whatYear > 2009
  4. {
  5. $iTax = 17.5;
  6. }
  7. else
  8. {
  9. $iTax = 15;
  10. }


I got this far by looking at the PHP manual, and doing a couple of searches on tinterweb.

Will it work, or am I being a Doofus?

:-)


Chris
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

Close...you're missing a few parentheses. Try this:

Code: [ Select ]
<?php

if(date("Y") > 2009) {
    $iTax = 17.5;
} else {
    $iTax = 15;
}
    
?>
  1. <?php
  2. if(date("Y") > 2009) {
  3.     $iTax = 17.5;
  4. } else {
  5.     $iTax = 15;
  6. }
  7.     
  8. ?>
  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Posts: 86
  • Loc: Liverpool

Post 3+ Months Ago

Thanks UPSGuy, your help is appreciated

:-)


Chris

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 68 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.