It would be better if we can assign return value of function to property.
If not at least we should generate a nice error message.
Currently when we try to assign return value of function to property we get
the following error:
Parse error: syntax error, unexpected '(', expecting ',' or ';' in
in
In all major programming languages we access object properties and methods
using dot(.).
C#:
Abc Abc = new Abc();
Abc.method();
Java:
Abc Abc = new Abc();
Abc.method();
JavaScript:
var apple = new function() {
this.name = "Test";
}
alert(apple.name());
Why not to make PHP similar to these
Partial Classes
If we are using same class for different purposes we can extend it, and add
new properties and methods. But we will also have to use new class name,
when we create objects. C# provides a better concept "Partial Classes". Why
not to also implement it in PHP?
Example:
Partial Class
We use 'use' keyword to import other namespaces, namespace classes,
namespace functions, and namespace constants.
Example
1) use abc; (Import abc namespace)
2) use abc\ClassB; (Import ClassB from abc namespace)
3) use function abc\sayhello; (Import sayhello function from abc namespace)
4) use con