Notice: Undefined variable: name in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: hometown in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: location in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: birthday in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: collegeid in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: college in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: majorid in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: major in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: grad in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: company in C:\xampp\htdocs\OOP\teststudent.php on line 60
Notice: Undefined variable: jobtitle in C:\xampp\htdocs\OOP\teststudent.php on line 60
To instantiate the object:
<?php
require_once('class.Student.php');
$objStudent = new Student($name,$hometown,$location,$birthday,$collegeid,$college,$majorid,$major,$grad,$company,$jobtitle,$interests);
$objStudent->name = $user_profile['name'];
$objStudent->hometown = $user_profile['hometown']['id'];
$objStudent->location = $user_profile['location']['id'];
$objStudent->birthday = $user_profile['birthday'];
$objStudent->collegeid = $user_profile['education'][1]['school']['id'];
$objStudent->college = $user_profile['education'][1]['school']['name'];
$objStudent->majorid = $user_profile['education'][1]['concentration'][0]['id'];
$objStudent->major = $user_profile['education'][1]['concentration'][0]['name'];
$objStudent->grad = $user_profile['education'][1]['year']['name'];
$objStudent->company = $user_profile['work'][0]['employer']['name'];
$objStudent->jobtitle = $user_profile['work'][0]['position']['name'];
$objStudent->eduRecommender();
?>
And the constructor:
<?php
class Student {
public $name;
public $hometown;
public $location;
public $birthday;
public $college;
public $major;
public $grad;
public $company;
public $jobtitle;
public $interests;
public function __construct($name,$hometown,$location,$birthday,$collegeid,$college,$majorid,$major,$grad,$company,$jobtitle,$interests) {
$this->name = $name;
$this->hometown = $hometown;
$this->location = $location;
$this->birthday = $birthday;
$this->collegeid = $collegeid;
$this->college = $college;
$this->majorid = $majorid;
$this->major = $major;
$this->grad = $grad;
$this->company = $company;
$this->jobtitle = $jobtitle;
$this->interests = $interests;
}
function eduRecommender() {
if ($this->majorid=='104076956295773') {
?>
<h2>You're on the right track!</h2>
<p>Majoring in Computer Science is definitely a giant leap forward. It's important, however, that you focus your energies on the technologies you'll be utilizing in the workplace at Facebook.</p>
<?php
} else {
?>
<h2>You need to major in Computer Science</h2>
<p>You're currently a <?php echo "$this->major" ?> major at <?php echo "$this->college" ?>. We recommend changing your major to Computer Science as it greatly improves your chances of success. As an alternative, declaring a minor in Computer Science would also be a major help.</p>
<?php
}
?>

New Topic/Question
Reply



MultiQuote







|