troubleshooting Question

explain this code and static values

Avatar of rgb192
rgb192Flag for United States of America asked on
PHP
6 Comments2 Solutions359 ViewsLast Modified:
<?php

$originalValue = "5'10\"";
echo "{$originalValue} = " . Converter::ToInches($originalValue) . " total inches!\n";

$originalValue = "female";
echo "{$originalValue} = " . Converter::ToInches($originalValue) . " total inches!\n";


class Converter
{
  public static function ToInches($original)
  {
    if(preg_match("/^(\d+)'(\d+)\"/",$original,$matches))
    {
          $feet = intval($matches[1]);
          $inches = intval($matches[2]);
          return ($feet * 12) + $inches;
    }
    else
    {
          throw new Exception("I don't understand the value {$original}!");
    }
  }
}

Please explain the reason why this code works

I am learning about object oriented program and static values.

Why is a static value best for this requirement?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros