A very simple PHP question ...

  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Joined: Sep 01, 2004
  • Posts: 86
  • Loc: Liverpool
  • Status: Offline

Post December 29th, 2009, 7:07 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post December 29th, 2009, 7:07 am

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Joined: Jul 25, 2005
  • Posts: 2735
  • Loc: Nashville, TN
  • Status: Offline

Post December 29th, 2009, 8:35 am

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. ?>
I'd love to change the world, but they won't give me the source code.
  • HongKongPhooey
  • Student
  • Student
  • User avatar
  • Joined: Sep 01, 2004
  • Posts: 86
  • Loc: Liverpool
  • Status: Offline

Post December 29th, 2009, 8:43 am

Thanks UPSGuy, your help is appreciated

:-)


Chris

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 176 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.