OOP Enquery in PHP [closed]











up vote
-3
down vote

favorite












I have below code



class student implements studentInterface {
private $amount = null;

public function amount() {
echo gettype($this -> amount); // Why object
}
}


Why I am getting Object type ?










share|improve this question













closed as off-topic by iainn, Rasclatt, yivi, Michael Dodd, eyllanesc Nov 21 at 16:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – iainn, Rasclatt, yivi, Michael Dodd, eyllanesc

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Because $this -> amount is object? Fiddle with your code shows what expected 3v4l.org/eKKdO
    – u_mulder
    Nov 21 at 14:34












  • Thanks @u_mulder. But I know that $this is a Object. Thanks.
    – abu abu
    Nov 21 at 14:38






  • 3




    The code you've posted doesn't so anything other than declare a class. Unless that class also has a setter method for $amount or a constructor, the property can't ever be anything other than null. If we can't see any more code, there's no help we can give you.
    – iainn
    Nov 21 at 14:42

















up vote
-3
down vote

favorite












I have below code



class student implements studentInterface {
private $amount = null;

public function amount() {
echo gettype($this -> amount); // Why object
}
}


Why I am getting Object type ?










share|improve this question













closed as off-topic by iainn, Rasclatt, yivi, Michael Dodd, eyllanesc Nov 21 at 16:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – iainn, Rasclatt, yivi, Michael Dodd, eyllanesc

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Because $this -> amount is object? Fiddle with your code shows what expected 3v4l.org/eKKdO
    – u_mulder
    Nov 21 at 14:34












  • Thanks @u_mulder. But I know that $this is a Object. Thanks.
    – abu abu
    Nov 21 at 14:38






  • 3




    The code you've posted doesn't so anything other than declare a class. Unless that class also has a setter method for $amount or a constructor, the property can't ever be anything other than null. If we can't see any more code, there's no help we can give you.
    – iainn
    Nov 21 at 14:42















up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











I have below code



class student implements studentInterface {
private $amount = null;

public function amount() {
echo gettype($this -> amount); // Why object
}
}


Why I am getting Object type ?










share|improve this question













I have below code



class student implements studentInterface {
private $amount = null;

public function amount() {
echo gettype($this -> amount); // Why object
}
}


Why I am getting Object type ?







php oop






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 14:28









abu abu

1,01921439




1,01921439




closed as off-topic by iainn, Rasclatt, yivi, Michael Dodd, eyllanesc Nov 21 at 16:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – iainn, Rasclatt, yivi, Michael Dodd, eyllanesc

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by iainn, Rasclatt, yivi, Michael Dodd, eyllanesc Nov 21 at 16:08


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – iainn, Rasclatt, yivi, Michael Dodd, eyllanesc

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 1




    Because $this -> amount is object? Fiddle with your code shows what expected 3v4l.org/eKKdO
    – u_mulder
    Nov 21 at 14:34












  • Thanks @u_mulder. But I know that $this is a Object. Thanks.
    – abu abu
    Nov 21 at 14:38






  • 3




    The code you've posted doesn't so anything other than declare a class. Unless that class also has a setter method for $amount or a constructor, the property can't ever be anything other than null. If we can't see any more code, there's no help we can give you.
    – iainn
    Nov 21 at 14:42
















  • 1




    Because $this -> amount is object? Fiddle with your code shows what expected 3v4l.org/eKKdO
    – u_mulder
    Nov 21 at 14:34












  • Thanks @u_mulder. But I know that $this is a Object. Thanks.
    – abu abu
    Nov 21 at 14:38






  • 3




    The code you've posted doesn't so anything other than declare a class. Unless that class also has a setter method for $amount or a constructor, the property can't ever be anything other than null. If we can't see any more code, there's no help we can give you.
    – iainn
    Nov 21 at 14:42










1




1




Because $this -> amount is object? Fiddle with your code shows what expected 3v4l.org/eKKdO
– u_mulder
Nov 21 at 14:34






Because $this -> amount is object? Fiddle with your code shows what expected 3v4l.org/eKKdO
– u_mulder
Nov 21 at 14:34














Thanks @u_mulder. But I know that $this is a Object. Thanks.
– abu abu
Nov 21 at 14:38




Thanks @u_mulder. But I know that $this is a Object. Thanks.
– abu abu
Nov 21 at 14:38




3




3




The code you've posted doesn't so anything other than declare a class. Unless that class also has a setter method for $amount or a constructor, the property can't ever be anything other than null. If we can't see any more code, there's no help we can give you.
– iainn
Nov 21 at 14:42






The code you've posted doesn't so anything other than declare a class. Unless that class also has a setter method for $amount or a constructor, the property can't ever be anything other than null. If we can't see any more code, there's no help we can give you.
– iainn
Nov 21 at 14:42














1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










You've defined $amount as null. null is untyped so, if you expect something besides "object", you need to call settype($amount, ...) or assign a typed value to $amount.






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    You've defined $amount as null. null is untyped so, if you expect something besides "object", you need to call settype($amount, ...) or assign a typed value to $amount.






    share|improve this answer

























      up vote
      0
      down vote



      accepted










      You've defined $amount as null. null is untyped so, if you expect something besides "object", you need to call settype($amount, ...) or assign a typed value to $amount.






      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        You've defined $amount as null. null is untyped so, if you expect something besides "object", you need to call settype($amount, ...) or assign a typed value to $amount.






        share|improve this answer












        You've defined $amount as null. null is untyped so, if you expect something besides "object", you need to call settype($amount, ...) or assign a typed value to $amount.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 15:01









        user1361991

        581613




        581613















            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)