php - Fatal error: Call to undefined method User::getSkipper() -
I'm trying to teach OOP myself in PHP, there is an error in my class, do anyone know that I Why is this error getting? Fatal error: Call the undefined method: User: getSkipper () in C: \ wamp \ www The user category is: The Captain class is: Error thrown when executing the following code:
& lt ;? Php class user {protected $ _first_name} Protected $ _last_name; Secure $ _ Email; Public function __ conversion ($ first_name, $ last_name, $ email) {$ this- & gt; _first_name = $ first_name; $ This- & gt; _last_name = $ last_name; $ This- & gt; _email = $ email; } Public Function getFirstName () {Return $ $$-> _first_name; } Public function getLastName () {return $ this- & gt; _last_name; } Public Function getEmail () {Return $ this- & gt; _email; }}? & Gt;
& lt ;? Php square Captor protects the user {protected $ _skipper; Public Function __construct ($ first_name, $ last_name, $ email, $ captain) {$ this- & gt; _skipper = $ Captain; } Public event getSkipper () {Return $ $-> _cipper; }}? & Gt;
$ user1 = New user ('Steven', 'Smith', 'Steve @ SledgeJacks DJ com ',' yes'); Echo & lt; P & gt; first name: '. $ User1- & gt; GetFirstName () '& Lt; / P & gt; '; Echo '& lt; P & gt; last name:'. $ User1- & gt; GetLastName () '& Lt; / P & gt; '; Echo '& lt; P & gt; E-mail:'. $ User1- & gt; GetEmail () '& Lt; / P & gt; '; Echo & lt; P & gt; Captain: '. $ User1- & gt; GetSkipper () '& Lt; / P & gt; ';
You create an object in the class user
and users There is no way getSkipper
to be used, you should create an object of class Skipper
.
$ user1 = new skipper ('steven', 'smith', 'steve @ seljagsdsd.com', 'yes');
Comments
Post a Comment