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 a variable's value is assigned to another variable, changing the value of one of the variables will not affect the other.
Copy Code code as follows:
<?php <?php
$a = 123; $a = 123;
$b = $a; $b =& $a;
$a = 321; $a = 321;
echo "$a, $b";//Display "321,123" echo "$a, $b";//Show "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 to be assigned (source variable)
Type trick PHP does not require (or support) an explicit type definition in a variable definition; the variable type is determined by the context in which the variable is used. That is, if you assign a string value to variable Var, var becomes a string. If you assign an integer value to Var, it becomes an integer.
Type cast
The allowed casts are: (int), (integer)-converted to integer (bool), (Boolean)-Converted to Boolean (float), (double), (real)-converted to floating-point type (string)-converted to string (array)-turn Replace with Array (object)-Convert to Object Settype () for type conversion
function Settype ()
[Code]
<?php
$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 context in which it is defined (that is, its active scope). Most PHP variables have only a single range. This single range span also contains files introduced by include and require.
Another important feature of the scope of a static variable variable is a static variable (variable). A static variable exists only in a local function field, but its value is not lost when the program executes out of this scope.
Arrays in PHP are actually an ordered graph. A diagram is a type that maps values to the keys. This type is optimized in many ways, so you can use it as a real array, or a list (vector), a hash list (a realization 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 simulate a tree.
Define array () to create a new array using the array () language structure. It accepts a certain number of key => value parameter pairs separated by commas.
Array (key => value, ...)
Key can be an integer or string
Value can be any value
Copy Code code as follows:
<?php//Now delete all of these cells, but keep the structure of the array itself
Creates a simple array 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 the 0 you might think)
$array [] = 6;
Print_r ($array); Re-indexing:
$array = Array_values ($array);
$array [] = 7;
Print_r ($array);
?>
The unset () function allows you to cancel the key name in an array. Be aware that the array will not rebuild the index.
Copy Code code as follows:
? Php
$a = Array (1 => ' one ', 2 => ' two ', 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 are array (0 => ' one ', 1 => ' three ')
?>
Constructors
void __construct ([Mixed $args [, $ ...]])
The PHP 5 allowable developer defines a method as a constructor in a class. Classes with constructors Call this method the first time you create an object, so it is ideal to do some initialization before using the object.
Note: If a constructor is defined in a subclass, it does not implicitly invoke the constructor of its parent class. To execute the constructor of the parent class, you need to call Parent::__construct () in the constructor of the subclass.
Example#1 using the new standard constructor
Copy Code code as follows:
<?php
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. Single quotes inside the not to explain, direct output. $ABC = ' My name is Tom '; echo $ABC//Results are my name is Tom Echo ' $abc '//result is $abc;echo "$ABC"//result is the My name is Tom
Access Controls access control over a property or method by adding the keyword public, protected, or private earlier. A class member defined by public can be accessed anywhere; A class member defined by protected can be accessed by subclasses and the parent class of the class in which it resides (of course, the class in which the member is also accessible), whereas a class member defined by private can only be accessed by its class.
Copy Code code as follows:
<?php
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 the Abstraction class 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. A method that is defined as abstract is merely a signal that declares a method and cannot define its implementation.
When inheriting from an abstract class, the declaration of markup for all abstract methods in the parent class must be defined by subclasses, and the methods must be defined with the same Access property. For example, if a method is defined as a protected type, the execution function must be defined as protected or public.
The interface object interface allows you to create an execution code for a method that specifies the class, without having to explain how the methods are manipulated (handled). Interfaces are used to define the use of interface keywords, as well as as a standard class, but no method has any definition of their content. All methods in an interface must be declared public, which is an attribute of the interface. Implements (execution, implementation) to implement an interface, the implements operation is used. All methods in an interface must be implemented within a class, and negligence will result in a fatal error. A class can implement multiple interfaces if it is desired to separate each interface by using a comma.
Overloaded method calls and member accesses can be loaded through the __call,__get and __set methods. These methods will be triggered only if you attempt to access an object that does not include a member or method or an inherited object. Not all overloaded methods must be defined as static. Starting with PHP 5.1.0 You can also overload the Isset () and unset () functions by __isset () and __unset () methods.
The PHP $_get variable is getting "value" from the form by a GET method. When you use the "$_get" variable, all variable names and variable values are displayed in the URL address bar, so you can no longer use this method when you send a message that contains a password or some other sensitive information.
The function of the PHP $_post variable is to get the form variable sent by method = "POST".
Case
Copy Code code as follows:
<form action= "welcome.php" method= "POST" >
Enter Your Name:
<input type= "text" name= "name"/>
Enter Your Age:
<input type= "text" name= "age"/>
<input type= "Submit"/>
</form>
Cookies are often used to authenticate or identify a user. A cookie is a small file sent through the server to a user's computer. Each time, when the same computer requests a page through the browser, the cookie that was stored is sent to the server. You can use PHP to create and get the value of cookies.
Copy Code code as follows:
<?php
Setcookie ("User", "Alex Porter", Time () +3600);?>
Get Cookie Value <?php
Print a cookie
echo $_cookie["user"];
A way to view all cookies
Print_r ($_cookie);
?>
PHP session variable is to store the user's session information, or change the user's session settings. The session variable stores a single user's information, which can be used by all pages.
<?php session_start ()?> The MVC pattern separates the application representation from the underlying application logic into 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, indicating 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 local resolution 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 rewrite engine hpptd.conf (no # is open module) #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 Code code as follows:
<virtualhost *:80>
ServerName Phpweb20
DocumentRoot "D:\appserv\www\phpweb20\htdocs"
<directory "D:\appserv\www\phpweb20\htdocs" >
AllowOverride All
Options All
</Directory>
Php_value include_path ".; D:\appserv\www\phpweb20\include;d:\appserv\php5\ext "
</VirtualHost>
4, create. htaccess
5. Modify PHP.ini
C:\WINNT
Import
Php_pdo.dll
Php_pdo_mysql.dll