Cases
The code is as follows
Copy Code
$a = 12;function fn (){Global $a;//using outer $a variables, $a as local variables without using this method$a +=12;}echo ' $a = '. $a//output result?>Results of output: $a =24
Commonly used keywords in a class
1.FIANL: Lock2.self: Somewhat similar to the This keyword3.static: Static Properties4.const: constant keyword
1. Keywords: fianl
An important keyword used to define classes and methods, which cannot be inherited
The difference between define () and const:
Define () defines constants during the execution period, while Const defines constants at compile time. This will have a slight speed advantage (ie a slightly better performance), but it is not worth
The so-called value pass, which means that only the value of the object is passed to the target object, which is equivalent to copy; The system will reopen a completely identical memory space for the target object.
A reference, that is, passing an
PHP Instance gzip Transfer page
The code is as follows
Copy Code
Can be used for static resources and HTML pages, which are also suitable for other languagesCache Expiration Time (Cache-control, http1.1), recommended for
Method 1:
(The best way) in php.ini add Find Date.timezone, set date.timezone = "Asia/shanghai", restart the environment is OK.
Method 2:
When you need to use these time functions, add Date_default_timezone_set ("PRC") to the page;
Method 3:
In
Intercepting stringsMb_substr ($str, Star,count,encode);Get string lengthMb_strlen ();Carriage return wrap complete in textarea textStr_replace (CHR), "", $textarea);
Return the corresponding letter based on ASCIIecho "ASCII is a 66 letter:". Chr (6
The code is as follows
Copy Code
/** $NAME; Upload file name* $size: Upload file size* $PATH; File Original path* $newpath: Set a new path* $not: An array of file types that are prohibited from uploading* $notsize: Limit the value
The code is as follows
Copy Code
Class HTML{var $dir; Dir for the htmls (www.111cn.net/)var $rootdir; Root of HTML files (www.111cn.net/): HTMLvar $name; HTML File Store pathvar $dirname; The specified folder namevar $url; Gets the
Caching technology:Some information, such as the constant, but still variable information in the cache to speed up the display speed, this is very valuable, the so-called cache, popular understanding is a number of stored on the server side of the
Usage:1. First create the uploadfile directory in the root directory2. "Value" and "graph": this is used to upload the image to the parent window. Value, which is the file name and can be used for input. Graph, which is an image and used for the
To create a directory in php, we will use the mkdir () function to create a directory.*/ The code is as follows:Copy code $ Dir = "abc ";If (mkdir ($ dir, 0777 )){Echo 'directory '. $ dir. 'Created successfully ';}Else{Echo 'failed to create
/** Function: PHP image watermark (watermarks support images or text)* Parameters:* $ GroundImage: specifies the background image to be Watermark. Currently, only GIF, JPG, and PNG formats are supported;* $ WaterPos watermark position, which has 10
As a popular Web programming language, the biggest advantage of PHP is speed.PHP4 is already doing very well in this regard, and you can hardly find a script programming language that is faster than it. However, if your application load is large,
This class can be used in mass mailing mode. The Test environment is linux, and sendmail must be installed in the system before it can be used.If (! Defined ('mail _ CLASS_DEFINED ')){Define ('mail _ CLASS_DEFINED ', 1 );Class email {Function email (
The code is as follows:Copy code /*** Obtain the server ip address* @ Access public* @ Return string**/Function real_server_ip (){Static $ serverip = NULL; If ($ serverip! = NULL ){Return $ serverip; } If (isset ($ _ SERVER )){If (isset ($ _
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service