$name and name ?? considered same by PHP ?
Posted: Tue Nov 25, 2014 7:06 am
Below is my object oriented programme to display a persons name :
[/syntax]
and the person.php file :
now in the index file if i comment out the below two lines :
when i run the programme i get the following output :
now how is that possible when in the person file i have the below :
and i have delared this :
now is $name and name the same thing ????
Code: Select all
[syntax=php]
<?php
require 'person.php';
$person = new person;
$person->name = "Gautam";
$person->age = 17;
echo $person->details();
?>
and the person.php file :
Code: Select all
<?php
/**
*
*/
class Person
{
public $name = "Ketan";
public $age = 19;
function details()
{
return $this->name . ' is ' . $this->age . ' years old ';
}
}
?>Code: Select all
$person->name = "Gautam";
$person->age = 17;Code: Select all
Ketan is 19 years old
Code: Select all
return $this->name . ' is ' . $this->age . ' years old '; Code: Select all
public $name = "Ketan";
public $age = 19;