Mb_detect_encoding () ($STR);
The code is as follows
Copy Code
Determine what the string is encodedif ($tag = = mb_convert_encoding (mb_convert_encoding ($tag, "GB2312", "UTF-8"), "UTF-8", "GB2312")) {}else {//if the gb23
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
Example 1
PHP's own functions can remove/remove HTML tags/codes from strings.
Strip_tags (String,allow): Functions strip HTML, XML, and PHP tags.
Parameters: String, required, specify the strings to be checked, allow, optional, specify the labels
PHP time is generally used in the form of large integers is stored and called. The time () function returns a Unix timestamp for the current time.
Definitions and usage
The time () function returns a Unix timestamp for the current time.
Grammar
Test program execution time in various environments in thinkphp projects do not use caching:
The code is as follows
Copy Code
Header ("Content-type:text/html;charset=utf-8");$starttime =caltime ()//Start time$articles
Json_encode This function is to play the role of data transfer between different languages, especially PHP for the data exchange between JS is very convenient.
But there are a few things to note when using this Json_encode function:
1 The data
Var_dump ()
void Var_dump (mixed expression [, mixed expression [, ...]])
The Var_dump () method is to determine the type and length of a variable and output the value of the variable if the variable has a value that is the value of the variable
The code is as follows:Copy code Include 'MySQL. Php ';$ Mysql = mysql: getObject ();$ Mysql-> query ("SELECT * FROM post ");$ Xml = new XMLWriter ();$ Xml-> openUri ('Hello. XML'); // or 'php: // output'$ Xml-> setIndentString ('');$ Xml->
The code is as follows:Copy code Function: addcomment Adds a comment. Parameters:$ Data-associative array of data, must contain 'name', 'Website', 'comment', 'date', 'User _ IP', 'User _ agent ', and 'spam '. Returns:Id of the new
User-defined function implementation pyramid The code is as follows:Copy code /*** Pyramid* String fun_py (int $ rows = 9, bool $ sort = true)* $ Rows indicates that the number of rows must be an integer and must be between 1 and 20* $ Sort
The code is as follows:Copy code /** Use PHP to determine whether a remote image (File) exists* Http://www.111cn.net*/Function check_remote_file_exists ($ url ){$ Curl = curl_init ($ url ); // Do not retrieve dataCurl_setopt ($ curl,
To obtain a short connection, you need to convert the short connection to a real url. By checking the information, we found that PHP provides a function get_headers () to complete this task, first obtain the header information, and then analyze the
Basic informationE_NOTICE indicates that it is not recorded in general cases and used only when the program has an error, for example, an attempt to access a non-existent variable or call the stat () function to view a non-existent file.E_WARNING is
PHP and HTMLPHP and HTML can interoperate: PHP can generate HTML, while HTML can transmit information to PHP. 1. How can I encode/decode the code when I use a form/URL to transmit values? 2. I am marking with , but the $ foo. x and $ foo. y
How to add a system user in PHP is a routine. Add a user named james and the root password is verygood. For reference only$ Sucommand = "su -- login root -- command ";$ Useradd = "useradd ";$ Rootpasswd = "verygood ";$ User = "james ";$ User_add =
Php and html separation program// QQ: 695703951, I don't know the master's brother. I have some personal instructions. Learn fast...Class fc_view{Var $ fc_dir;// Specify the DirectoryVar $ fc_file;// View fileVar $ fc_aval = array ();// ArrayVar $
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