Pass array key to a function

i am still in diapers when it comes to classes. I know nothing about classes and i do not have time to master classes. by the time i could fully understand and utilize classes, i could have a fully functioning classless website. i am trying o learn about classes in my spare time. i am not a programmer in the sense that i do not get paid to program. i am not very good at backend code. i am just trying to build my nture website and help others whenever i can do so.

i just started studying classes using the php manual. i didn’t even understand how to access a private function directly until yesterday. here is the result of my class file study for the day:

test1.php

<?php
  Class Foo {

    public $var = 'bar variable value';

      public function bar() {
        return 'bar function return value';
      }
  }
?>
<?php
  $obj = new Foo();
  echo $obj->var, PHP_EOL, $obj->bar(), PHP_EOL;
  exit;
?>

test2.php accessing the function (which i couldn’t find an answer to this question, so i decided to try the this-> method and it worked. i hacked it to understand it.)

<?php
  Class Foo {

    public $var = 'Foo variable value';

      public function barrow() {
        return $this->bar();
      }
      private function bar() {
        return 'Foo bar function return value';
      }
  }
?>
<?php
  $obj = new Foo();
  echo $obj->var, PHP_EOL, '<br>', $obj->barrow(), PHP_EOL;
  echo '<br>';
  exit;
?>

as you can see, i am still in diapers. but my main focus is biology, which you can see from my code in the zip file. i also made a video of my site. i forgot to send it to Jim.

Sponsor our Newsletter | Privacy Policy | Terms of Service