我可以将php集中在php中输入变量类吗?

In Java, everything object, I know which type it is, for example... I will doing something like this:

MyObject aObject = new MyObject();

I always know that the "aObject" is MyObject...

but PHP, I use this

$aObject = new MyObject();

I don't know what is the "aObject" was, I try to doing this, it gives me error:

MyObject $aObject = new MyObject();

It makes me feel very focus on that, any suggestions? Thank you.

You can make great use of comments like that

// data type is MyObject
$aObject = new MyObject();

You might want to read PHP: Type Juggling, and PHP: Type Hinting on php.net.

That is, unfortunatley for you, how PHP works. There are no strict data-types in PHP, what so ever. It is something that you have to grow into to be a PHP-programmer.

No, in PHP you can do Type juggling:

$aObject = new MyObject();
$aObject = new UnrelatedObject();

is perfectly valid PHP. It's not necessarily a bad thing though. It has both pros and cons.