. Represents a string addition, and a. $ in Java as a prefix for variables. Variable name definition rule with Java parameter passing and method return simultaneous references need to be prefixed &
Demo Sample code:
function f (& $a) {}//method parameters passed in as a reference
Functioin & F () {}//method return value returned as a reference
Reflection calling method in Java variable function in PHP corresponding to: Var a =< Span style= "Font-family:mathjax_main; Font-style:normal; Font-weight:normal; " > " a " A (); PHP is a bit more powerful than Java when defining variables, and can define mutable variables, that is, when defining variables. The variable name itself can be used with a variable.
Demo Sample code:
Var a = " a ; v a Span class= "Mi" id= "mathjax-span-353" style= "Font-family:mathjax_math; Font-style:italic; " >r a="usea";// ais aaamakewith The value of a is the variable name of the variable. can also use Var{a}= "Use a";
PHP classes must be loaded before they are used, otherwise they will error, unlike Java's use only to the class will cause the class to load itself actively. The code that loads the class such as the following:
function My_autoloader ( Class) {
Include ' classes/'. Class. '. class.php ';
}
Spl_autoload_register (' My_autoloader ');
PHP does not have a multi-threaded PHP constant defined by using the defined () function instead of final.
Demo Sample: 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 parent class when the object, which is the same as Java's thisphp, uses parent. This is the same as Java superphp, which uses self to represent the current class. Java does not have this keyword. There is no need to use a presentation class.
When PHP calls static variables and methods in this class, it must use Selfkeyword and:: To demonstrate the sample code:
Class A () {
public static function foo () {echo "foo";}
Self:: foo ();
}
Assume that the class name is not used directly in this class:
Class A () {
public static function foo () {echo "foo";}
}
A:: foo ();
Not to be continued.
。
PHP basic syntax and the difference from Java