Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Assign default property value

Sun Oct 26, 2008 11:35 pm

Code:
<?php
    
class Employee {
        public 
$title       "product";
        public 
$mainName    "main";
        public 
$firstName   "first";
        public 
$price       0;
        
        function 
getFullName() {
            return 
"{$this->firstName}".
                   
" {$this->mainName}";
        }
    }

$product1 = new Employee();
$product1->title "title";
$product1->mainName  "A";
$product1->firstName "B";
$product1->price 5.99;

print 
"author: ".$product1->getFullName()."\n";
?>




Post a reply
  Related Posts  to : Assign default property value
 Usage of the CSS property !important     -  
 php Accessing a Property from Within a Method     -  
 Show image using before property     -  
 Use the 'default' case     -  
 String type default value     -  
 Function with default parameters     -  
 Default Initial Values in java     -  
 How to change the default order on forums from ascending to     -  
 Default Expire time for Session JAVA     -  
 Remove default window icon from JFrame     -  

Topic Tags

PHP OOP