PHP OOP only accessing first line of text file - php

I am doing an assignment for school, and I am having an odd problem. The object that I have created only accesses the first line of a text file we are using. This is highly problematic for me because if I build a database and can only use the first line, well, so much for usefulness.
My instructor and I both can't figure out why this problem is here, and we have worked on this for over a week.
Here is the text file:
003345, Pauline, Sampson, Admin, 14.96
012345, Mike, King, Manager, 20.47
123456, Pete, Smith, Accountant, 25.53
345678, Mary, Jones, Accountant, 32.53
456789, Mary, King, Manager, 18.35
777999, Caroline, Baxter, Nurse, 27.45
Here is my start HTML:
<!DOCTYPE html>
<html>
<head>
<title>Modify1.html</title>
<link rel ="stylesheet" type="text/css" href="sample.css" />
</head>
<body>
<h1>Weekly Pay report</h1>
<form action="modify1.php" method="post">
<table>
<tr><td>Employee ID 1</td><td><input type="text" name="id1"></td></tr>
<tr><td>Employee ID 2</td><td><input type="text" name="id2"></td></tr>
<tr><td>Employee ID 3</td><td><input type="text" name="id3"></td></tr>
</table>
<p><input type = "submit" value = "Submit">
</form>
</body>
</html>
Here is my PHP output:
<!DOCTYPE html>
<html>
<head>
<title>Modify 1</title>
<link rel ="stylesheet" type="text/css" href="sample.css" />
</head>
<body>
<?php
include("inc-employee-object.php");
$id1 = $_POST["id1"];
$id2 = $_POST["id2"];
$id3 = $_POST["id3"];
$emp1 = new Employee();
$emp2 = new Employee();
$emp3 = new Employee();
$emp1->findEmployee($id1);
$emp2->findEmployee($id2);
$emp3->findEmployee($id3);
print ("<p>Weekly Pay for ".$emp1->getFirstName()." ". $emp1->getLastName().": $".$emp1->getWeeklyPay()."</p>");
print ("<p>Weekly Pay for ".$emp2->getFirstName()." ". $emp2->getLastName().": $".$emp2->getWeeklyPay()."</p>");
print ("<p>Weekly Pay for ".$emp3->getFirstName()." ". $emp3->getLastName().": $".$emp3->getWeeklyPay()."</p>");
?>
</body>
</html>
And here is my object:
<?php
class Employee
{
private $empID;
private $firstName;
private $lastName;
private $jobTitle;
private $hourlyWage;
public function addEmployee()
{
$empRecord = $this->empID.",
".$this->firstName.",
".$this->lastName.",
".$this->jobTitle.",
".$this->hourlyWage."\n";
$empFile = fopen("employees.txt", "a");
fputs($empFile, $empRecord);
fclose($empFile);
}
public function findEmployee($id)
{
$empFile = fopen("employees.txt", "r");
$empRecord = fgets($empFile);
$notFound = true;
while (!feof($empFile) and $notFound)
{
list ($empID, $fName, $lName, $title, $wage) = explode(",", $empRecord);
if ($id == $empID)
{
$this->empID = $empID;
$this->firstName = $fName;
$this->lastName = $lName;
$this->jobTitle = $title;
$this->hourlyWage = $wage;
$notFound = false;
}
if ($notFound == false)
{
return 1;
}
else
{
return 0;
}
$empRecord = fgets($empFile);
}
fclose($empFile);
}
public function getID()
{
return $this->empID;
}
public function setID($empID)
{
$this->empID = $empID;
}
public function getFirstName()
{
return $this->firstName;
}
public function setFirstName($fName)
{
$this->firstName = $fName;
}
public function getLastName()
{
return $this->lastName;
}
public function setLastName($lName)
{
$this->lastName = $lName;
}
public function getJobTitle()
{
return $this->jobTitle;
}
public function setJobTitle($title)
{
$this->jobTitle = $title;
}
public function getHourlyWage()
{
return $this->hourlyWage;
}
public function setHourlyWage($hourlyWage)
{
$this->hourlyWage = $hourlyWage;
}
public function getWeeklyPay()
{
$this->hourlyWage = trim($this->hourlyWage);
return number_format ($this->hourlyWage * 40, 2);
}
public function getAnnualPay()
{
$this->hourlyWage = trim($this->hourlyWage);
return number_format($this->hourlyWage * 40 *52,2);
}
} // end of class definition
?>
Can anyone tell me what I'm doing wrong?
Thanks

In your while loop, you will always exit on the first item due to this code...
if ($notFound == false)
{
return 1;
}
else
{
return 0;
}
Under any condition, this will exit out of the loop and function. This should be outside the loop and probably at the end of the function.
If you want to stop the loop once the record is found, then use break; something like...
if ($id == $empID)
{
$this->empID = $empID;
$this->firstName = $fName;
$this->lastName = $lName;
$this->jobTitle = $title;
$this->hourlyWage = $wage;
$notFound = false;
break; // Exit loop
}

#NigelRen is right about the loop exiting once a condition is found. But that may be by your design and should not matter in this case as you are calling the class separately for each id.
If you look at the your text file you are missing commas in between the wage and the employee id's. So it is only seeing the first row and not the others.
Cheers!

Related

Problem when printing specific array data

I'm working with a player class, the code prints a form with name, lastname and location fields that have to be filled in to add a new player.
But I have a problem when printing the players since I only print the names of the players, when I try to print the data separately (name, lastname and location) I do not print anything.
session_start();
class Player {
private $players;
private $name;
private $lastname;
private $location;
public function __construct($name,$lastname,$location)
{
$this->name = $name;
$this->lastname = $lastname;
$this->location = $location;
$this->players = array();
}
public function getName()
{
return $this->name;
}
public function getLastname()
{
return $this->lastname;
}
public function getLocation()
{
return $this->location;
}
public function addPlayer($onePlayer)
{
$this->players[] = $onePlayer;
return $this;
}
public function printPlayers()
{
foreach($this->players as $player){
// just show the name¿?.
echo $player.'<br />';
// The problem is here.
/*echo $player['name'].'<br />';
echo $player['lastname'].'<br />';
echo $player['location'].'<br />';*/
}
}
public function __toString()
{
return $this->name;
return $this->lastname;
return $this->location;
}
}
function printForm()
{
echo '<FORM METHOD="POST" style="text-align: center; margin-top: 73px;">
<h2>Add Players</h2>
<label>Add the name : </label><INPUT class="form" TYPE = "text" NAME = "name"> <br>
<label>Add the lastname : </label><INPUT class="form" TYPE = "text" NAME = "lastname"> <br>
<label>Add the location : </label><INPUT class="form" TYPE = "text" NAME = "location"> <br><br>
<INPUT class="form" TYPE = "submit" VALUE = "add" name="action">
<INPUT class="form" TYPE = "submit" VALUE = "list" name="action">
</ FORM>';
}
// Load the player data of the session and if it does not exist create a new player.
function loadData()
{
return isset($_SESSION['player']) ? $_SESSION['player'] : new Player();
}
// Save the player's data in the session.
function saveData($player)
{
$_SESSION['player'] = $player;
}
printForm();
$player = loadData();
if(isset($_POST['action']))
{
switch($_POST['action'])
{
case 'add':
$player->addPlayer(new Player($_POST['name'],$_POST['lastname'],$_POST['location']));
saveData($player);
break;
case 'list':
echo '<hr />';
$player->printPlayers();
break;
}
}
It looks like in the problematic part you're trying to access private properties using array syntax. That won't work for a couple of reasons
The properties aren't accessible there because they're defined as private
You can't get them with array syntax. If they weren't private you'd need to use $player->name.
But fortunately you have also written some getters, so you should be able to use those instead, like this:
echo $player->getName();

Convert PHP 5.6 news script to 7.2

I have a PHP 5.6 compatible script. Now in my server i have to change to php7.2, but this script get error everywhere.I want to convert it myself but my knowledge does not reach much. I have been advancing little by little with several tutorials but I have already been stuck without being able to continue.
I need help to do it myself. This is just an example of the code, but by solving this, I think I will be able to convert the whole site.
The error:
[01-Nov-2018 09:16:58 UTC] PHP Fatal error: Uncaught Error: Call to a member function query() on null in /home/xxxx/public_html/incs/generales/fullnews.php:433
Stack trace:
#0 /home/xxxx/public_html/news.php(16): FullNewsInc->getFullNews('18880', 'fullnews')
#1 {main}
thrown in /home/xxxx/public_html/incs/generales/fullnews.php on line 433
the news.php page
<?php
require_once './db.php'; $db = new DB_Sql(); $db2 = new DB_Sql();
include_once './fullnews.php';
$fullnewsinc = new FullNewsInc($db);
$newsId = $_REQUEST['newsId'];
$system = $_REQUEST['system'];
$cat = $_REQUEST['categorie'];
?>
<section id="main-content" itemscope itemtype="https://schema.org/Article">
<div id="latest">
<section class="noticias">
<div class="clearfix"></div>
<?php $fullnewsinc->getFullNews($newsId, 'fullnews'); ?>
</section>
<aside class="sidebar">
</aside>
</div> <!-- END Latest -->
<div class="clearfix"></div>
</section>
This is the function in fullnews.php
<?php
class FullNewsInc {
var $db;
public function __construct()
{
// Constructor's functionality here, if you have any.
}
public function FullNewsInc(&$db) {
$this->db = &$db; self::__construct();
}
function getFullNews($newsId = '', $template = 'theme_fullnews') {
$sql = "SELECT x FROM";
$this->db->query($sql);
while($this->db->next_record()) {
$newsId = $this->db->f("newsId");
$subject = $this->db->f("subject");
$shortNews = $this->db->f("shortNews");
$longNews = $this->db->f("longNews");
$iconId = $this->db->f("iconId");
$source = $this->db->f("source");
include "./theme/".$template.".tpl.php";
}
}
}?>
This is the db.php
<?php
if (!class_exists('DB_Sql')){
class DB_Sql {
public function __construct()
{
// Constructor's public functionality here, if you have any.
}
public $Host = "xxx";
public $Database = "xxxx";
public $User = "xxx";
public $Password = "xxxxx";
public $Auto_Free = 1;
public $Debug = 0;
public $Halt_On_Error = "no"; // "yes", "no", "report"
public $Record = array();
public $Row;
public $Errno = 0;
public $Error = "";
public $Link_ID = 0;
public $Query_ID = 0;
public function DB_Sql($query = "") {
$this->query($query);self::__construct();
}
public function link_id() {
return $this->Link_ID;self::__construct();
}
public function query_id() {
return $this->Query_ID;self::__construct();
}
public function connect($Database = "", $Host = "", $User = "", $Password = "") {
if ("" == $Database)
$Database = $this->Database;
if ("" == $Host)
$Host = $this->Host;
if ("" == $User)
$User = $this->User;
if ("" == $Password)
$Password = $this->Password;
if ( 0 == $this->Link_ID ) {
$this->Link_ID=#mysqli_connect($Host, $User, $Password, $Database);
if (!$this->Link_ID) {
$this->halt("connect failed - Please check your database settings.");
die;
}
if (!#mysqli_select_db($Database,$this->Link_ID)) {
$this->halt("cannot use database ".$this->Database." - Please check your database settings.");
die;
}
}
return $this->Link_ID;
}
public function free() {
#mysql_free_result($this->Query_ID);
$this->Query_ID = 0;self::__construct();
}
public function query($Query_String) {
if ($Query_String == "") {
return 0;
}
if (!$this->connect()) {
return 0;
}
# New query, discard previous result.
if ($this->Query_ID) {
$this->free();
}
if ($this->Debug)
printf("Debug: query = %s<br />\n", $Query_String);
$this->Query_ID = #mysqli_connect($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;self::__construct();
}
public function next_record() {
if (!$this->Query_ID) {
$this->halt("next_record called with no query pending.");
return 0;
}
$this->Record = #mysqli_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
$this->free();
}
return $stat;self::__construct();
}
public function affected_rows() {
return #mysql_affected_rows($this->Link_ID);self::__construct();
}
public function num_rows() {
return #mysql_num_rows($this->Query_ID);self::__construct();
}
public function num_fields() {
return #mysql_num_fields($this->Query_ID);self::__construct();
}
public function nf() {
return $this->num_rows();self::__construct();
}
public function np() {
print $this->num_rows();self::__construct();
}
public function f($Name) {
return $this->Record[$Name];self::__construct();
}
public function p($Name) {
print $this->Record[$Name];self::__construct();
}
public function halt($msg) {
$this->Error = #mysqli_error($this->Link_ID);
$this->Errno = #mysqli_errno($this->Link_ID);
if ($this->Halt_On_Error == "no")
return;
$this->haltmsg($msg);
if ($this->Halt_On_Error != "report")
die("Session halted.");self::__construct();
}
public function haltmsg($msg) {
printf("<b>Database error:</b> %s<br />\n", $msg);
printf("<b>MySQL Error</b>: %s (%s)<br />\n",
$this->Errno,
$this->Error);self::__construct();
}
}
}
The theme_fullnews tamplate:
<article>
<header>
<h1 itemprop="name" ><?php echo $subject; ?></h1>
<h2 itemprop="articleSection"><?php echo $shortNews; ?></h2>
<span itemprop="datePublished" content=" <?php echo $newDate; ?>"> <?php echo time_elapsed_string($timestamp); ?> </span>
</div>
</header>
<section>
<?php $longNews); ?>
</section>
</article>
What's happening here is that you have functions inside your class with the same name as the class. PHP is warning you that the ability to do this is going to be removed in future.
For example, you have your php class
<?php
class FullNewsInc {
public function __construct( )
{
// Constructor's public functionality here, if you have any.
}
/**
Some code here
**/
public function FullNewsInc($db){
$this->db = &$db;
}
/**
More code here
**/
}
The class and method name match, so you would need to change your PHP class to use the __construct method, which you've written, but it is currently blank.
class FullNewsInc {
public function __construct( $db )
{
// Constructor's public functionality here, if you have any.
$this->db = &$db;
}
/**
Some code here
**/
//The FullNewsInc method has been deleted. The code contained within was moved to the __construct
/**
More code here
**/
}
There is more information available on the php.net site http://php.net/manual/en/language.oop5.decon.php

PHP initializing a class while calling a function with arguments

In php, i would like to call the initialized properties of the class while calling function with arguments but can't seem to figure it out. Below is my source code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Task 25 NOvember 2015</title>
</head>
<body>
<?php
class Task{
public $name = "abc";
public $fname = "xyz";
public $dob = "10-9-90";
public $country = "country";
public $ddress = "Street";
public $cgpa = 3;
public $degree = "MCS";
public $year = "2014";
public function method1($arg1, $arg2, $arg3){
$this->name = $arg1;
$this->fname = $arg2;
$this->dob = $arg3;
return "My name is ".$this->name." ".", and my father name is ".$this->fname;
//i want to print the above values ... without giving in the function args
}
public function method2($arg4,$arg5){
}
public function method3(){}
public function method4(){}
public function method5(){}
}
$object1 = new Task();
echo $object1->method1("","","");
?>
</body>
</html>
I'm a new php programmer, I would like to figure out how I can make the initialized properties of the class to the function arguments that echo that initialized values when calling functions through objects of that class.
You are replacing the initial values to empty string in you code:
echo $object1->method1("","","");
try :
<?php
class Task
{
public $name = "Naveed";
public $fname = "Zahid";
public $dob = "10-04-1991";
public $country = "Pakistan";
public $ddress = "shergarh mardan kpk";
public $cgpa = 3.83;
public $degree = "MCS";
public $year = "2014";
public function method1($arg1, $arg2, $arg3) {
$this->name = $arg1;
$this->fname = $arg2;
$this->dob = $arg3;
return "My name is " . $this->name . " " . ", and my father name is " . $this->fname;
//i want to print the above values ... without giving in the function args
}
public function method2($arg4, $arg5) {
}
public function method3() {
}
public function method4() {
}
public function method5() {
}
}
$object1 = new Task();
echo $object1->method1("Naveed", "Zahid", "10-04-1991");
?>
Or if you really need to use the initialized values, do not put arguments and do not overwrite the initial values:
<?php
class Task
{
public $name = "Naveed";
public $fname = "Zahid";
public $dob = "10-04-1991";
public $country = "Pakistan";
public $ddress = "shergarh mardan kpk";
public $cgpa = 3.83;
public $degree = "MCS";
public $year = "2014";
public function method1() {
return "My name is " . $this->name . " " . ", and my father name is " . $this->fname;
//i want to print the above values ... without giving in the function args
}
public function method2($arg4, $arg5) {
}
public function method3() {
}
public function method4() {
}
public function method5() {
}
}
$object1 = new Task();
echo $object1->method1();
?>
Also, try to learn more about basic/advance of PHP. you can start using this link: http://www.tutorialspoint.com/php/ tutorialspoint help me alot when studying new language

How the heck do I return these arrays with actual values from the db? Keep on coming up blank

So the ultimate goal is to print out products as objects in a table using functions from these classes, but the output is a table with the correct amount of rows/columns but they are blank. I've spent 3 hours trying to figure this out and I'm stumped. There's three files
Product.php
<?php
class Product
{
protected $product_id;
protected $product_name;
protected $product_price;
public function __construct($product_id,$product_name, $product_price = '')
{
$this->setProductID($product_id);
$this->setProductName($product_name);
$this->setProductPrice($product_price);
}
public function getProductID() {
return $this->product_id;
}
public function getProductName() {
return $this->product_name;
}
public function getProductPrice() {
return $this->product_price;
}
public function setProductID($product_id)
{
$this->product_id = $product_id;
}
public function setProductName($product_name)
{
$this->product_name= $product_name;
}
public function setProductPrice($product_price)
{
$this->product_price= $product_price;
}
}
ProductMapper.php
<?php
class ProductMapper
{
public function getProducts()
{
$dbConn = getDbConnection();
$stmt = $dbConn->prepare("SELECT * FROM product");
$stmt->execute();
$outArray = array();
while ($row = $stmt->fetch()) {
$outArray[] = new Product($row['product_id'], $row['product_name'], $row['product_cost']);
}
return $outArray;
}
}
and Index.php which is where it is outputted.
<?php
require('classes/functions.php');
require('classes/Product.php');
require('classes/ProductMapper.php');
$productMapper = new ProductMapper();
$rows = $productMapper->getProducts();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Product</title>
</head>
<body>
<tbody>
<?php
foreach ($rows as $row) {
echo "<tr>";
echo "<td>{$row->getProductID($this)}</td>";
echo "<td>{$row->getProductName($id)}</td>";
echo "<td>{$row->getProductPrice($id)}</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</body>
</html>
There are a few minor issues with the code that you provide which prevent it working. Do you have 'error_reporting' set error-reporting?
index.php :
The 'getProduct' methods do not accept any parameters. So you should not call them with any parameters.
ProductMapper.php :
for consistancy i renamed the 'product_cost' column to 'product_price'.
i injected the database connection in the constructor and made it a property. Makes available the connection for any future method.
Some example output:
pid01 name-pid01 23.34
pid02 name-pid02 101.67
Here are the new scripts...
index.php
require('classes/functions.php');
require('classes/Product.php');
require('classes/ProductMapper.php');
$productMapper = new ProductMapper(getDbConnecton());
$rows = $productMapper->getProducts();
// note: the 'getProductID', 'getProductName' and 'getProductPrice' methods
// do not accept or need, any parameters.
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Product</title>
</head>
<body>
<table>
<tbody>
<?php
foreach ($rows as $row) {
echo "<tr>";
echo "<td>{$row->getProductID()}</td>";
echo "<td>{$row->getProductName()}</td>";
echo "<td>{$row->getProductPrice()}</td>";
echo "</tr>";
}
?>
</tbody>
</table>
// ProductMapper.php
class ProductMapper
{
/**
* #var PDO
*/
private $dbConn = null;
public function __construct(PDO $pdo)
{
$this->dbConn = $pdo;
}
public function getProducts()
{
$dbConn = $this->dbConn;
$stmt = $dbConn->prepare("SELECT * FROM product");
$stmt->execute();
$outArray = array();
while ($row = $stmt->fetch()) {
$outArray[] = new Product($row['product_id'], $row['product_name'], $row['product_price']);
}
return $outArray;
}
}

the form does not print out the details

I have created a form in html which takes all the information using the method post in php to print them out for the user but its seems like that I have a problem with my form. It does not print out the entered details by the user, I have tried to fill up and then press submit to create an object of the class profile assigning all the information from the user to the object and print them out on the browser but nothing appear on the browser.
I have also tried to echo the methods like getFirstName but its the same nothing comes up, can anyone help me to find out whats the problem with the code and how can I fix it.
Please note that I have included three different files one is the html form and the other one is the passingdata.php which will get all the information entered by the user and the third file is the class profile which is used in the passingdata to create an object and give it all the needed information in order to create an object of that class.
Finally, I have invoked the method printDeatils which should print out all the information entered by the user
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><?php echo 'Student Deatils'; ?></title>
</head>
<body>
<p>Please enter your Details:</p>
<div>
<form name="student" method="post" action="passingdata.php">
<div>
<label>First name:</label> <input type ="text" name="first_name">
<label>Last name</label> <input type ="text" name="last_name">
<br></br>
<label>International student</label> <input type="checkbox" name="international">
<br></br>
<fieldset>
<legend>Course</legend>
<label>CS <input type="radio" name="course" value="CS"></label>
<label>SE <input type="radio" name="course" value="SE"></label>
<label>MIT <input type="radio" name="course" value="MIT"></label>
</fieldset>
<br></br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Resit" value="Reset">
</div>
</form>
</div>
<?php
?>
</body>
</html>
The passing data file:
<?php
require("profile.php");
$ss = new Profile($_POST['first_name'], $_POST["last_name"],
$_POST["course"], $_POST["international"]);
echo $ss->printDtails();
?>
The class profile:
<?php
class Profile {
private $_firstName, $_lastName, $_international, $_course;
function __contruct ($firstName, $lastName, $course, $international) {
$this->_firstName = $firstName;
$this->_lastName = $lastName;
$this->_course = $course;
$this->_international = $international;
}
public function setFirstName($firstName)
{
$this->_firstName = $firstName;
}
public function setLastName($lastName)
{
$this->_lastName = $lastName;
}
public function setInternational($inter)
{
$this->_international = $inter;
}
public function setCourse($course)
{
$this->_course = $course;
}
public function getFirstName()
{
return $this->_firstName;
}
public function getLastName()
{
return $this->_lastName;
}
public function getInternational()
{
return $this->_international;
}
public function getCourse()
{
return $this->_course;
}
public function printDtails()
{
echo "$_firstName";
}
}
?>
In the printDtails() function you need to echo $this->_firstName
Also in your class, the word construct is spelled wrong, you have __contruct it needs to be __construct
This worked for me, however I did modify your code slightly.
I must admit that I'm learning classes myself, so this may or may not be what you're looking for, however it did work.
Also, inside your printDtails() function, it needed a echo $this->_firstName; etc.
I changed your constructs to $this->_firstName = $_POST['first_name']; etc.
N.B.: The word construct was mispelled as contruct with the missing s
Here is what I came up with:
<?php
class Profile {
private $_firstName, $_lastName, $_international, $_course;
function __construct ($_firstName, $_lastName, $_international, $_course)
{
$this->_firstName = $_POST['first_name']; // modified
$this->_lastName = $_POST['last_name']; // modified
$this->_course = $_POST['course']; // modified
$this->_international = $_POST['international']; // modified
}
public function setFirstName($firstName)
{
$this->_firstName = $firstName;
}
public function setLastName($lastName)
{
$this->_lastName = $lastName;
}
public function setInternational($inter)
{
$this->_international = $inter;
}
public function setCourse($course)
{
$this->_course = $course;
}
public function getFirstName()
{
return $this->_firstName;
}
public function getLastName()
{
return $this->_lastName;
}
public function getInternational()
{
return $this->_international;
}
public function getCourse()
{
return $this->_course;
}
public function printDtails()
{
echo $this->_firstName . "\n"; // modified
echo $this->_lastName . "\n"; // modified
echo $this->_course . "\n"; // modified
echo $this->_international . "\n"; // modified
}
}
?>

Categories