Transfer Value Assignment: When you assign the value of an expression to a variable, the value of the entire original expression is assigned to the target variable. This means that, for example, when the value of one variable is assigned to another variable, changing the value of one of the variables will not affect the other variable.
Copy CodeThe code is as follows:
$a = 123; $a = 123;
$b = $a; $b =& $a;
$a = 321; $a = 321;
echo "$a, $b";//Display "321,123" echo "$a, $b";//Display "321,321"
?>?>
Reference Assignment: The new variable simply references the original variable, and changing the new variable will affect the original variable using the reference assignment, simply adding a & symbol to the variable that will be assigned (source variable)
Type-trick PHP does not need (or does not support) explicit type definitions in variable definitions; The variable type is determined by the context in which the variable is used. In other words, if you assign a string value to Var, var becomes a string. If you assign an integer value to Var, it becomes an integer.
Type casting
Allowable casts are: (int), (integer)-Converted to int (bool), (Boolean)-Converted to Boolean (float), (double), (real)-converted to floating-point (string)-converted to string (array)-Go Switch to Array (object)-Convert to Object Settype () for type conversion
function Settype ()
[Code]
$foo = "5bar"; String
$bar = true; Boolean
Settype ($foo, "integer"); $foo is now 5 (integer)
Settype ($bar, "string"); $bar is now "1" (String)
?>
The scope of a variable range variable is the context in which it is defined (that is, its effective scope). Most PHP variables have a single range. This separate scope span also contains the files introduced by include and require.
Another important feature of the variable range of static variables is the static variable (variable). A static variable exists only in the local function domain, but its value is not lost when the program executes away from the scope.
An array of arrays in PHP is actually an ordered graph. A graph is a type that maps values to keys. This type is optimized in many ways, so it can be used as a real array, or a list (vector), a hash table (an implementation of the graph), a dictionary, a collection, a stack, a queue, and more possibilities. Because you can use another PHP array as a value, you can also easily emulate a tree.
Define an array () to create a new array with the array () language structure. It accepts a number of comma-separated key = value parameter pairs.
Array (key = value, ...)
Key can be an integer or string
Value can be any value
Copy CodeThe code is as follows:
Create a simple array of foreach ($array as $i = = $value) {
$array = Array (1, 2, 3, 4, 5); Unset ($array [$i]);
Print_r ($array); }
Print_r ($array);
Add a unit (note that the new key name is 5, not what you might think 0)
$array [] = 6;
Print_r ($array); Re-index:
$array = Array_values ($array);
$array [] = 7;
Print_r ($array);
?>
The unset () function allows you to cancel the key names in an array. Be aware that the array will not rebuild the index.
Copy CodeThe code is as follows:
$a = Array (1 = ' one ', 2 = ' both ', 3 = ' three ');
Unset ($a [2]);
/* will produce an array, defined as
$a = array (1=> ' one ', 3=> ' three ');
Instead of
$a = Array (1 = ' one ', 2 = ' three ');
*/
$b = array_values ($a);
Now $b is array (0 = ' one ', 1 = ' three ')
?>
constructor function
void __construct ([Mixed $args [, $ ...])
PHP 5 allows the developer to define a method as a constructor in a class. Classes with constructors Call this method each time an object is created, making it ideal for doing some initialization work before using the object.
Note: If a constructor is defined in a subclass, the constructor for its parent class is not called secretly. To execute the constructor of the parent class, you need to call Parent::__construct () in the constructor of the child class.
Example#1 using the new standard constructor
Copy CodeThe code is as follows:
Class BaseClass {
function __construct () {
Print "in BaseClass constructor\n";
}
}
Class Subclass extends BaseClass {
function __construct () {
Parent::__construct ();
Print "in subclass constructor\n";
}
}
$obj = new BaseClass ();
$obj = new Subclass ();
?>
The fields inside the double quotes are interpreted by the compiler and then exported as HTML code. The single quotation mark inside does not interpret, the direct output. $ABC = ' My name is Tom '; echo $ABC//Results are my name is Tom; Echo ' $abc '//result is $abc;echo "$ABC"//results are my name is Tom
Access control access control to a property or method is achieved by adding the keyword public, protected, or private earlier. A class member defined by public can be accessed anywhere, and a class member defined by protected can be accessed by the subclass and parent of its class (of course, the class where the member resides), while a class member defined by private can only be accessed by the class in which it resides.
Copy CodeThe code is as follows:
Class MyClass
{
Public $public = ' public ';
Protected $protected = ' protected ';
Private $private = ' private ';
function Printhello ()
{
Echo $this->public;
Echo $this->protected;
Echo $this->private;
}
}
Abstract classes and abstract methods are introduced in PHP 5. Creating an instance of a class that is already defined as abstract is not allowed. Any class that contains at least one abstract method must also be abstract. Methods that are defined as abstractions are merely a signal for declaring methods and do not define their implementation.
When inheriting from an abstract class, the declaration of the tokens of all abstract methods in the parent class must be defined by the subclass, and these methods must be defined with the same access properties. For example, if a method is defined as a protected type, the execution function must be defined as protected or public.
Interface object interfaces allow you to create execution code for a method of a specified class without having to explain how the methods are manipulated (handled). Interfaces are used to define the use of interface keywords, as well as a standard class, but there is no way to define their contents. All methods in an interface must be declared public, which is an attribute of the interface. Implements (execution, implementation) in order to implement an interface, the implements operation is used. All methods in an interface must be implemented within a class; negligence of these will result in a fatal error. If you desire to separate each interface by using a comma, the class can implement multiple interfaces.
Overloaded method calls and member accesses can be loaded through the __call,__get and __set methods. These methods will only fire when you try to access an object that does not include a member or method or inherit an object. Not all overloaded methods must be defined as static. The Isset () and unset () functions can be overloaded individually from PHP 5.1.0 by using the __isset () and __unset () methods.
The PHP $_get variable gets the value from the form using the Get method. When you use the "$_get" variable, all variable names and variable values are displayed in the URL address bar, so when you send a message that contains a password or some other sensitive information, you can no longer use this method.
The PHP $_post variable is used to obtain form variables that are sent by method = "POST".
Case
Copy CodeThe code is as follows:
Cookies are often used to authenticate or identify a user. A cookie is a small file that is sent to a user's computer by a server. Each time a page is requested by the same computer through a browser, the previously stored cookie is also sent to the server. You can use PHP to create and get the value of a cookie.
Copy CodeThe code is as follows:
Setcookie ("User", "Alex Porter", Time () +3600);?>
Get Cookie Value Print a cookie
echo $_cookie["user"];
A-to-View all cookies
Print_r ($_cookie);
?>
The role of the PHP session variable is to store the user's session information, or to change the user's session settings. The session variable stores a single user's information, which can be used by all pages.
The MVC pattern separates the applied representations from the underlying application logic in three parts: Model View Controller
When a zend_controllers route sends a user request, It automatically looks for a file named namecontroller.php in the Controller directory, where name corresponds to the controller name specified, which indicates that the controller named news corresponds to a file named newscontroller.php
Smarty is a php-written template engine that allows you to easily separate application output from presentation logic and application logic
Zend Configuration
1. Create a local parsing C:\WINNT\system32\drivers\etchosts
127.0.0.1 Phpweb20 127.0.0.1 phpMyAdmin
2, httpd.conf D:\AppServ\Apache2.2\conf
(1) Open the rewrite engine hpptd.conf (no # is the module that can be opened) #LoadModule Rewrite_module
Get rid of the front #
(2) Open the virtual host #Include conf/extra/httpd-vhosts.conf remove the front #
3, httpd-vhosts.conf
Copy CodeThe code is as follows:
ServerName Phpweb20
DocumentRoot "D:\appserv\www\phpweb20\htdocs"
AllowOverride All
Options All
Php_value include_path ".; D:\appserv\www\phpweb20\include;d:\appserv\php5\ext "
4, create. htaccess
5, modify the php.ini
C:\WINNT
Import
Php_pdo.dll
Php_pdo_mysql.dll
http://www.bkjia.com/PHPjc/322746.html www.bkjia.com true http://www.bkjia.com/PHPjc/322746.html techarticle Value Assignment: When assigning the value of an expression to a variable, the value of the entire original expression is assigned to the target variable. This means, for example, when a variable's value is given to another variable ...