40 tips to optimize your PHP code
The English copyright belongs to Reinhold Weber, the author of Yangyang (aka Davidkoree). The bilingual version may be used for non-commercial communication, provided that the English version of the author,
explanation One:
In PHP, there is the concept of string.
In string, the size of each character is byte (compared to PHP, each character in Java is character, which is the UTF8 character, and each character in the C language can be selected at
strlen function prototype extern unsigned int strlen (char *s); in Visual C + + 6.0, the prototype is size_t strlen (const char *string); , where size_t is actually unsigned int, you can see the code in VC6.0: typedef unsigned int size_t;. Header
1.char array type and null characterC does not define a specific variable type for a string, but instead stores it in a char array. The last position of the array displays the character. This character is a null character, C is used to mark the end
1. If a method C++an be static, declare it static. Speed improvement are by a factor of 4. If a method is static, it is statically declared. The rate can be increased to 4 times times.2. Echo is faster than print. echo is faster than print.3. Use
1. If a method C++an be static, declare it static. Speed improvement is by a factor of 4. If a method is static, it can be statically declared. The rate can be raised to 4 times times.
2. Echo is faster than print. echo is faster than print.
3.
1. It is quicker to use single quotes instead of double quotes to contain strings. Because PHP searches for variables in a string enclosed in double quotes, single quotes are not, note: only echo can do this, it is a "function" that can take
For example, I have a multidimensional array $relationshop_list, which has IDs, with sort two columns, and I want the array to be sorted in descending order of ID, sorted in sort of way:Sort$array _field = Array_column ($relationshop _list, ' sort ')
echo is faster than print.Use Echo's multiple parameters instead of string concatenation.To determine the maximum number of loops before executing the FOR loop, do not compute the maximum value per loop, preferably by using foreach instead.For
Strlen ()
PHP strlen () function
Definitions and usage
The strlen () function returns the length of the string.
Grammar
Strlen (String)
Parameters: StringDescription: Required. Specify the string to check.
The code is as follows
CVE-2015-3795
Http://blog.wuntee.sexy/CVE-2015-3795/
0x00 background
This vulnerability was reported to Apple in June 4. This vulnerability was fixed in the 10.10.5 security update released on April 9, August 13.
Related information:Apple
//the ASCII code value of 0 is//It's all strings . Charname1[8] ="it"; Charname2[8] = {'I','T',' /'}; Charname3[8] = {'I','T',0}; Charname4[8] = {'I','T'}; //not a string (only an array of characters). CharName5[] = {'I','T'};/* the role of
C language-06 complex data type-02 string,-06-02
# Include int main () {// char name [] = {'I', 't', 'C', 'h', 's','t ', '\ 0'}; char name [] = "itcast"; name [3] = 'H';/* int size = sizeof (name ); printf ("% d \ n", size); */printf ("I attended
Often, developers find it useful to use this data structure in PHP to sort values or array elements. PHP provides a number of sorting functions that are suitable for multiple arrays, which allow you to arrange elements within an array, and also
String processing has a large number of character or string processing functions in php. Let's summarize the learning notes on PHP string processing today, this is not only a learning note, but also has great advantages in developing
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.