-
Classes and Objects
about 9 years ago
-
almost 4 years ago
Become part of the community of life long learners with Industry based education and become a relevant professional of tomorrow -
-
about 9 years ago
Welcome to Findnerd. I just checked your code in which you created a function named person and created a object, passing the arguments name and age in it. Oops concept is same in javascript and PHP but the way they use this concept is different. If you create the class person in php then you can do it like this.
class Person { public var $personName; public var $personAge; function Person($name,$age){ echo $this->personName = $name; echo $this->personAge = $age; } function message(){ echo 'success shown'; } } $object = new Person('Deepak','24'); $object->message();
You can check the above script in which we created class Person , its constructor and a function named message. In Javascript we create the object of the function.
Thank you
Deepak Verma -
2 Answer(s)