Total members 11895 |It is currently Sun Dec 22, 2024 2:53 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Code:
<?php
    
class Employee {
        public 
$title;
        public 
$lastName;
        public 
$firstName;
        public 
$price;
        
        function 
__construct$title$firstName$mainName$price ) { 
            
$this->title     $title;
            
$this->firstName $firstName;
            
$this->lastName  $mainName;
            
$this->price     $price;
        }

        function 
getFullName() {
            return 
"{$this->firstName}" " {$this->lastName}";
        }
    }
    
class 
EmployeeWriter {
    public function 
write$shopProduct ) {
        
$str  "{$shopProduct->title}: ";   
        
$str .= $shopProduct->getFullName();
        
$str .= " ({$shopProduct->price})\n";
        print 
$str;
    }
}
$product1 = new Employee"Title""A""B"5.9 );
$writer = new EmployeeWriter();
$writer->write$product1 );

?>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Pass class instance as parameter in php
 pass parameter     -  
 A clone instance of class in php     -  
 Create object instance from class Name by reflection     -  
 class with constructor parameter     -  
 What exact mean by Object, Reference and Instance?     -  
 pass CompTIA LX0-101 & LX0-102 Exam quickly     -  
 All 4 CCNA semesters in power point pass?     -  
 pass parameters to main method args[] variables     -  
 How can I pass a PHP variable to a window.onload event funct     -  
 get url parameter     -  



Topic Tags

PHP OOP






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com