1. Can the constructor return the value of the result in PHP?
No. (It was possible, but the problem has been fixed - if you see code that offers something else.)
2. When a member function inside the class calls another member function inside the class, do I need to use self :: scoping or is it just a hint?
This usually works technically, please do not do this. Inside object instances, $this to access its own properties and methods.
3. Why is there self :: and $ this-> and what's the difference?
This is not a complete answer, but for introduction: self:: is for static function calls and member access. See PHP: self vs. $ this .
4. Do I need to delete the object created using the new one or exit it, delete it? I'm not sure if it is really dynamic, or if garbage collection, like in C #.
You do not need to delete objects, there is a garbage collector. When objects leave the scope, they are deleted (the reference count to zval is one). Keep in mind that everything is deleted at the end of the request in PHP. Usually your application only works for a split second, and then the process memory is cleared just like script (and PHP) terminates.
source share