Jump to content

sfc

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by sfc

  1. Was my question too stupid? Sorry, I'm still very new at this.
  2. No. And I know that the way I am calling it right now is how you would call a Class variable, so I know it isn't right but I don't know how to call the variable inside the method. As you requested: class Student extends Classroom { static public $student_count = 0; public function __construct($student_name) { echo "Hello {$student_name}! <br />"; parent::__construct(); echo "The number of students in your class is: " . parent::$class_attendance . "<br /><br />"; self::$student_count++; } }
  3. public function __construct($student_name) { echo "Hello {$student_name}! <br />"; parent::__construct(); echo "The number of students in your class is: " . parent::$class_attendance . "<br /><br />"; self::$student_count++; } I want to access the $student_name variable through the instance but I don't know how... I tried this: echo "Student" . $student1->student_name . " is the same as student " . $student2->student_name.": "; echo ($student1 == $student2) ? "True" : "False"; but it didn't work. I am very new to OOP in PHP. What am I doing wrong? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.