This PHP tutorial mainly describes how to use static attributes and static methods in PHP and provides basic examples.
Static attributes mean that their values keep their values. For example, if n objects are instantiated in the class, you can
1. Static variables exist only in the function scope. Note: These variables will not be lost after execution (the variable will still remember the original value when the function is called next time ).
To define static variables, you only need to
Class math {Const Pi = 3.14;
Public static functions squared ($ v ){Return $ v * $ V;}
Public static function cubed ($ v ){Return self: squared ($ v) * $ V;}
Public static function circlearea ($ radius ){Return self: squared ($ radius) * Self:
First, Static class
Copy the following code, save as file static.class.php
1
Templet = ""; $this->datasource = Array (); $this->filename = ""; $this->mod = "WB"; $this->handle = false; 22}23//bound data source, parameter is an array of function
The following PHP code example, the function is to help the user to reset the password, Requestresetpassword is to receive the user to reset the password request and do a corresponding check. For better reusability, I assign the reset password
Static variables only exist in the function scope. That is to say, static variables only exist in the stack. Generally, variables in a function are released after the function ends, such as local variables, but static variables do not. That is to
How to update the static pages generated by PHP in batches now the static pages generated by PHP in batches need to be changed, and how to do it is better to demonstrate the code. do you need to use the for loop? share: more ---- how to update
Recently, I encountered a problem where all the news in the news system generated static content, but I want to display the dynamic content such as the number of visits on the static page. I have no good solutions. Today, I suddenly thought, can I
Copyright statement: You can reprint it at will. Please mark it as a hyperlink during reprinting.ArticleSource and author information and this statementThis article from: http://www.otm.cn Author: matrix @ two_max
Let's first review some basic
ArticleDirectory
Declaration scope.
Call Method
Lifecycle
Summary
I have been learning PHP for a while. Some things still need to be summarized. netProgramMany PHP concepts are different from previous ones. Here we will
Recently, when creating a website, you need to generate static pages. However, some content in the generated static pages must be obtained dynamically ..
Finally, I checked it online and added a summary .... Finally .. We will study it together ..
For example:
Class {
Public $ F1 = 'xxxx ';
Static public $ f2= 100;
}
If you want to assign a variable to an object, you can only initialize the variable in the constructor. For example:Class {Private $ child;Public Function _ construct (){$
Class createhtml
{
Function mkdir ($ prefix = 'Article ')
{
$ Y = Date ('y ');
$ M = Date ('M ');
$ D = Date ('D ');
$ P = directory_separator;
$ Filepath = 'Article'. $ P. $ Y. $ P. $ M. $ P. $ D;
$ A = explode ($ P, $ filepath );
Foreach ($ A as $
Template.htm:
CopyCode The Code is as follows:
% title %
% title %
% body %
PHP file: copy Code the code is as follows:
// replace function is used to replace the keywords in the content read from the template file with
Solution: Use the template replacement technology (no time delay) The code is as follows:Copy code /*| ------------------| | ------------------*/$ Users = $ _ POST ['users']; // add operationIf ($ region = 'ADD '){$ Title = $ _ POST ['title'];$
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.