Multiple design modes are used in ZendFramework. The database encapsulation uses the factory model. First, we will introduce some concepts:
Factory mode: defines a class to create instances of other classes. the created instance usually has its own
In PHP development, we often need to use some database classes. here we will briefly share the code for calling classes. For more information about php database operations, see
Copy codeThe code is as follows:
Require_once ("mssql. class. php ");
There are four common methods for using integer functions in PHP. four functions are collected below. the integer function is often used. let's take a short summary today! Actually, it's quite simple, just a few functions ~~ Mainly: ceil, floor,
Sometimes, we want to output a variable. if it is an array, var_dump. if it is a string or something like that, we can echo it. the is_scalar built-in function will be used in this case.
Is_scalar -- checks whether the variable is a scalar.
Today, the php version of the server is upgraded to 5.4.4, and a previous project is switched to apache. the dynamic second-level domain name resolution is implemented using. htcaccess and shared.
Copy codeThe code is as follows:
AuthName "yousite
The built-in template engine supports the use of functions for template variables, and supports multiple functions at the same time. note: User-defined functions should be placed in the project application directory/common. php. Here is the key.
In actual encoding, to view and operate the memory, many programmers first think of the PHP script memory function PHPmemory_get_usage (). below is the PHP memory_get_usage () Usage example:
Copy codeThe code is as follows:
Echo memory_get_usage
If the same key name exists in the same array, the value of the previous key name will be overwritten)
You can see a question on the Internet:
The result of array ("a") + array ("B") is ___
A. array ("a", "B ")B. array ("B", "")C. array ("B ")D.
Php magic methods _ get () and _ set () are introduced. if you need them, refer to the instructions in the official php documentation:
_ Set () is run when writing data to inaccessible properties.
_ Get () is utilized for reading data from
The five design modes of PHP mainly include the factory mode, single element mode, Observer Mode, command chain mode, and policy mode factory mode.
Single element mode
Observer Mode
Command chain mode
Rule mode
Copy codeThe code is as
The two methods and differences of array merging in PHP. if you need them, you can refer to the two methods and differences of PHP array merging.
If it is an associated array, as follows:
Copy codeThe code is as follows:
$ A = array (
'Where' =>
In actual projects or self-compiled gadgets (such as news aggregation, product price monitoring, and price comparison), data is usually obtained from the 3rd-party website or API, when you need to process a URL queue, to improve the performance, you
PHP uses AJAX to obtain the webpage and output the implementation code. For more information, see:
1. file_get_contents timeout control.
2. page encoding judgment.
3. press Enter to capture the response.
4. handle keyboard event compatibility. //
I feel that the code is not concise enough. I hope the experts can guide the modification. I have prepared a few more for you, so that you can easily test and learn basic things. I feel that the code is not concise enough, hope experts can guide the
As we all know, the results of cache database queries can significantly shorten the script execution time and minimize the load on the database server. This technology is very effective if the data to be processed is basically static. This is
PHP transparent watermark generation code. For more information, see
Copy codeThe code is as follows:
/*
* Created on 2010-10-27
* BY QQ542900563
* Copyrights Reserved 2000-2020
* This example shows how to generate an image watermark.
*/
//
Take a value and compare it with other values. put a small value on the left of the value, a large value on the right of the value, and then follow this method to recursively code 1:
Copy codeThe code is as follows:
Function quicksort ($ str ){
If
Three methods: count and sort the number of each character in a string. there are multiple solutions ~ The str_split () function is very important.
Copy codeThe code is as follows:
// This method is purely a back-function and is not
To accurately obtain information about the browser operating system of a user, PHP loads different CSS files to different users for different requirements, such as different IE users.
1. when a user accesses the SERVER, use the PHP Super global
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