. Represents the addition of strings
In Java.
$ as a prefix for variables, in addition to the variable name definition rules with Java
Parameter passing and method return simultaneous references need to be prefixed &
Example code:
function f (& $a) {}//method parameter value passed in as a reference
Functioin & F () {}//method return value returned as a reference
The reflection calling method in Java corresponds to a mutable function in PHP: var a= "a"; A ();
PHP is a bit more powerful than Java when defining variables, and you can define mutable variables, meaning that the variable name itself can be used as a variable when defining a variable.
Example code:
var a= "a"; var a= "Usea";//A is a variable that uses the value of a as a variable name, or var {a}= "use a";
PHP classes must be loaded before they are used, or they will error, unlike Java, which causes classes to load automatically as long as the class is used. The code for the load class is as follows:
function My_autoloader (Class) {
Include ' classes/'. class. '. class.php ';
}
Spl_autoload_register (' My_autoloader ');
PHP does not have multiple threads
PHP constants are defined not using final but with the defined () function. Example: Define ("CONSTANT", "Hello World");
PHP 5.3.0 also supports this way of defining: Const CONSTANT = ' Hello world ';
PHP calls the parent class's constructor instead of using super (), but Parent::__construct ().
PHP has destructors, similar to the Java Finalize method. For example: function __destruct () {print "Destroying";}
PHP uses this to represent the object, which is the same as the Java
PHP uses the parent to represent the parental class, which is the same as the Java super
PHP uses self to represent the current class, Java does not have this keyword, and it does not need to use a presentation class.
When calling static variables and methods in this class, PHP must use the Self keyword and::, Sample code:
Class A () {
public static function foo () {echo "foo";}
Self:: foo ();
}
If you are not in this class, use the class name directly:
Class A () {
public static function foo () {echo "foo";}
}
A:: foo ();
Not to be continued ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.