Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

 2 Answer(s)

  • 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

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: