Parse error: syntax error, unexpected '$triad' (T_VARIABLE)

I'm writing my first Object Oriented script and I'm getting the following error

Parse error: syntax error, unexpected '$triad' (T_VARIABLE) in /var/www/html/unademy/public_html/chord-speller/result.php on line 4

Here is my code

result.php

<?php
  include 'MajorTriad.php'

  $triad = new MajorTriad('C');
  echo $triad->getRoot();

?>

Open in new window


MajorTriad.php

<?php

  class MajorTriad {
      private $root;
      private $rootNumber;
      private $third;
      private $thirdNumber;
      private $fifth;
      private $fifthNumber;

      function __construct($root)
      {
          $this->root = $root;
      }

      protected function getChord()
      {
          $this->rootNumber = $this->getCorrespondingRootNumber($this->root);
          $this->thirdNumber = $this->getThirdNumber($this->rootNumber);
          $this->fifthNumber = $this->getFifthNumber($this->rootNumber);
          $this->third = $this->getChordNote($this->root, $this->thirdNumber);
          $this->fifth = $this->getChordNote($this->third, $this->fifthNumber);

          $chord = $this->root . $this->third . $this->fifth;

          return $chord;

      }

      protected function getRoot()
      {
          return $this->root;
      }

      protected function getThird()
      {
          return $this->third;
      }

      protected function getFifth()
      {
          return $this->fifth;
      }


      protected function getThirdNumber($rootNumber)
      {
          $this->thirdNumber = $rootNumber + 4;
      }

      protected function getFifthNumber($rootNumber)
      {
          $this->fifthNumber = $rootNumber + 7;
      }

      protected function getCorrespondingRootNumber($rootNote)
      {
          switch ($rootNote) {
              case 'G♯':
                  $this->rootNumber = 1;
                  break;
              case 'A♭':
                  $this->rootNumber = 1;
                  break;
              case 'A':
                  $this->rootNumber = 2;
                  break;
              case 'A♯':
                  $this->rootNumber = 3;
                  break;
              case 'B♭':
                  $this->rootNumber = 3;
                  break;
              case 'B':
                  $this->rootNumber = 4;
                  break;
              case 'C':
                  $this->rootNumber = 5;
                  break;
              case 'C♯':
                  $this->rootNumber = 6;
                  break;
              case 'D♭':
                  $this->rootNumber = 6;
                  break;
              case 'D':
                  $this->rootNumber = 7;
                  break;
              case 'D♯':
                  $this->rootNumber = 8;
                  break;
              case 'E♭':
                  $this->rootNumber = 8;
                  break;
              case 'E':
                  $this->rootNumber = 9;
                  break;
              case 'F':
                  $this->rootNumber = 10;
                  break;
              case 'F♯':
                  $this->rootNumber = 11;
                  break;
              case 'G♭':
                  $this->rootNumber = 11;
                  break;
              case 'G':
                  $this->rootNumber = 12;
                  break;
              default:
                  die('Error assigning root number');
          }
      }

      protected function getChordNote($thirdBelow, $number)
      {
          $letterNote = $this->getLetter($thirdBelow);
          $currentLetter = $this->thirdUp($letterNote);

          switch ($number) {
              case 1:
                  if (strpos('G♯', $currentLetter)) $chordTone = 'G♯';
                  elseif (strpos('A♭', $currentLetter)) $chordTone = 'A♭';
                  break;
              case 2:
                  if (strpos( 'G𝄪', $currentLetter)) $chordTone = 'G𝄪';
                  elseif (strpos('A', $currentLetter)) $chordTone = 'A';
                  elseif (strpos('B𝄫', $currentLetter)) $chordTone = 'B𝄫';
                  break;
              case 3:
                  if (strpos('A♯', $currentLetter)) $chordTone = 'A♯';
                  elseif (strpos('C𝄫', $currentLetter)) $chordTone = 'C𝄫';
                  elseif (strpos('B♭', $currentLetter)) $chordTone = 'B♭';
                  break;
              case 4:
                  if (strpos('A𝄪', $currentLetter)) $chordTone = 'A𝄪';
                  elseif (strpos('B', $currentLetter)) $chordTone = 'B';
                  elseif (strpos('C♭', $currentLetter)) $chordTone = 'C♭';
                  break;
              case 5:
                  if (strpos('B♯', $currentLetter)) $chordTone = 'B♯';
                  elseif (strpos('C', $currentLetter)) $chordTone = 'C';
                  elseif (strpos('D𝄫', $currentLetter)) $chordTone = 'D𝄫';
                  break;
              case 6:
                  if (strpos('B𝄪', $currentLetter)) $chordTone = 'B𝄪';
                  elseif (strpos('C♯', $currentLetter)) $chordTone = 'C♯';
                  elseif (strpos('D♭', $currentLetter)) $chordTone = 'D♭';
                  break;
              case 7:
                  if (strpos('C𝄪', $currentLetter)) $chordTone = 'C𝄪';
                  elseif (strpos('D', $currentLetter)) $chordTone 'D';
                  elseif (strpos('E𝄫', $currentLetter)) $chordTone = 'E𝄫';
                  break;
              case 8:
                  if (strpos('D♯', $currentLetter)) $chordTone = 'D♯';
                  elseif (strpos('E♭', $currentLetter)) $chordTone = 'E♭';
                  elseif (strpos('F𝄫', $currentLetter)) $chordTone = 'F𝄫';
                  break;
              case 9:
                  if (strpos('D𝄪', $currentLetter)) $chordTone = 'D𝄪';
                  elseif (strpos('E', $currentLetter)) $chordTone = 'E';
                  elseif (strpos ('F♭', $currentLetter)) $chordTone = 'F♭';
                  break;
              case 10:
                  if (strpos('E𝄪', $currentLetter)) $chordTone = 'E♯';
                  elseif (strpos('F', $currentLetter)) $chordTone = 'F';
                  elseif (strpos('G𝄫', $currentLetter)) $chordTone = 'G𝄫';
                  break;
              case 11:
                  if (strpos('E𝄪', $currentLetter)) $chordTone = 'E𝄪';
                  elseif (strpos('F♯', $currentLetter)) $chordTone = 'F♯';
                  elseif (strpos('G♭', $currentLetter)) $chordTone = 'G♭';
                  break;
              case 12:
                  if (strpos('F𝄪', $currentLetter)) $chordTone = 'F𝄪';
                  elseif (strpos('G', $currentLetter)) $chordTone = 'G';
                  elseif (strpos('A𝄫', $currentLetter)) $chordTone = 'A𝄫';
                  break;
              default:
                  die('Error in getChordNote method');
           }
      }


      protected function getLetter($note)
      {
          if (strpos($note, 'A')) $letterNote = 'A';
          elseif (strpos($note, 'B')) $letterNote = 'B';
          elseif (strpos($note, 'C')) $letterNote = 'C';
          elseif (strpos($note, 'D')) $letterNote = 'D';
          elseif (strpos($note, 'E')) $letterNote = 'E';
          elseif (strpos($note, 'F')) $letterNote = 'F';
          elseif (strpos($note, 'G')) $letterNote = 'G';
          else
           {
              $letterNote = null;
              die('error in getLetter method');
          }

          return $letterNote;
      }

      protected function thirdUp($letterNote)
      {
          switch ($letterNote) {
              case 'A':
                  $nextNote = 'C';
                  break;
              case 'B':
                  $nextNote = 'D';
                  break;
              case 'C':
                  $nextNote = 'E';
                  break;
              case 'D':
                  $nextNote = 'F';
                  break;
              case 'E':
                  $nextNote = 'G';
                  break;
              case 'F':
                  $nextNote = 'A';
                  break;
              case 'G':
                  $nextNote = 'B';
                  break;
              default:
                  die('Error in method thirdUp()');
          }
            return $nextNote;
      }

  }
?>

Open in new window


Happy Thanksgiving
burnedfacelessAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you missing a semi colon before that line, try this:

<?php
  include 'MajorTriad.php';

  $triad = new MajorTriad('C');
  echo $triad->getRoot();

?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
burnedfacelessAuthor Commented:
Thanks man.

Now to figure out this encapsulation bulllshit.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.