Php static variables and custom constants⚑Declaration and use of static variables
⚑Usage of custom constants
What are static variables?
Static variables are variables declared using static. The difference between these variables and local variables
Php functions, classes and objects, class encapsulation, inheritance, class static methods, static attributes, php static
1. Functions Php built-in functions can be used directly. If php extensions are not installed Custom Functions
Php static page generation method
I. PHP scripts and dynamic pages.
A PHP script is a server-side scripting program that can be mixed with html files by embedding methods, classes, function encapsulation, and other forms to process user requests in
Summary of PHP static local static variables and Global static variables
The reason why static local variables are used is that they cannot be used externally, but their values are retained when they are not used. Although global variables can be
Class book{ public $name;//variables public static $price;//static variable Const id=1;//Constants function SetName ($name) {//member method $this->name= $name;//Access normal variable You can use the This keyword } function
To ensure compatibility with PHP4, if "visibility" is not specified, the attribute and method are considered public.Because static methods can be called without passing through objects, the pseudo variable $ this is not available in static
General function variables are released after the function ends, such as local variables, but static variables do not. The value of the variable is preserved the next time the function is called.Basic usage of static variables1. Defining static
Sometimes some static files (slices) will be output by PHP, will find that the request is 200, static files each time to go to the server to request too much waste of resources, then how to let the browser cache pictures? We need to output 304 in
Static class: A class that contains a static definition of the
Static PropertiesOr the class of the method
Static Class access Methods:
1, the static method does not need to instantiate the object, can be called directly through the class name, the
PHP static page generation tutorial. let's review some basic concepts first.
I. PHP scripts and dynamic pages.
A PHP script is a server-side scripting program that can be mixed with HTML files by embedding methods, classes, function encapsulation,
PHP static page explanation copyright statement: can be reproduced at will. during reprinting, please be sure to mark the original source and author information of the article and this statement in hyperlink form
This article from: http://www.otm.cn
Use PHP static variables as cache methods. The following PHP code instance helps you reset the password. requestResetPassword is used to receive and check the password reset request. For better reusability, the following PHP code instance is used to
This page describes defining static methods and properties with the static keyword. Static can also be used to define statically variable and late static bindings.
Declaring a class property or method as static can be accessed directly without
As shown below:
'; } static Public Function eat () {echo ' static method eats '; } public Function Intro () {echo $this->name; }}error_reporting (e_all| E_STRICT);//There are no objects at this time! The method can execute Human::eat ();/* The
How to use PHP static methods and attributes. As we all know, the goal of OOP is to write code once, copy, copy, inherit, inherit, and then inherit to make reasonable use of every job, and also facilitate code management. As we all know, the goal of
PHP static page generation
I. PHP scripts and dynamic pages.
PHP script is a server-side script program that can be embedded by
Methods are mixed with HTML files. They can also be in the form of classes or function encapsulation, and user requests
For PHP static page template generation + cache + file writing, refer to the code below. 1. Introduction
In terms of speed, static pages are much faster than dynamic pages, for example, php. this is without a doubt, but due to the poor flexibility
Php static variables used as cache instance tutorial
/**
* The receiver that the user requests to reset the password
*/
Function requestResetPassword (){
// Check whether the user exists
If (!
Php static page generation methods
// Method 1: generate a static page based on the template
// ReplaceTemplateString is used to replace the specified string in the template.
Function
PHP static page entry-unique196
/**
* Static PHP pages are divided into the following steps:
* 1. open the output control cache
* 2. return the content in the output cache.
* 3. write a string to a file
* 4. the content in the cache area is
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.