1

i'm sorry if this is a noob question, but i can't figure it out.

I have a .php file containing a class:

<?php
   class Visitors
   {
      public function greetVisitor()
      {
         echo "Hello<br />";
      }

      function sayGoodbye()
      {
         echo "Goodbye<br />";
      }
   }
?>

In another php file containing mostly HTML, i try to create an instance of this class and call the function greetVisitor :

            <div class="map col-md-4">
                <?php
                    $test = new Visitors();
                    $test->sayGoodbye();
                ?>
            </div>

For some reason this isn't displaying when i look in my browser. Any ideas ? tried doing a var_dump, but nothing is showing thanks

1 Answers1

0

Before you create an object of the class Visitors you need to include/require the php file where that class is defined, like this: By the way, do not use the parenthesis since you are not sending any values and yes you are a newbie!

milton cedeno
  • 58
  • 1
  • 4