PHP programming and its subtle details

Source: Internet
Author: User
Tags ultraedit

/////////////////
In Windows, notepad will convert the "UTF-8 encoded, bom-free" file into "Bom", that is, add three bytes of "Ef bb bf" before the file ". Because it seems that notepad can only save files for the UTF-8 with Bom. Remember!
It often appears when you use NotePad to modify the config. Inc. PHP configuration file of PHP. At this time, because config. Inc. php is generally contained in the header of the PHP file, if the PHP file involves the session or header () function, it will be troublesome. Before session or header (), HTML scripts, including ECHO output, are not allowed. Although the "Ef bb bf" string is invisible to the human eye, PHP regards them as HTML characters.

/////////////////
The ultraedit Editor automatically identifies whether the edited string is in English (single-byte encoding) or Chinese (Multi-byte encoding ). In addition, the ultraedit editor saves the text in an uncertain length encoding.
For example, the edited text is all in English, even if it is forcibly saved as a UTF-8, it is automatically saved as a single-byte text file in common DOS format in windows. At this time, the Chinese character is entered, and the Chinese character is still dubyte encoded.
The Chinese character is a three-byte encoding of the UTF-8 only when it is saved as a UTF-8 encoding again. English is always a single-byte encoding. This can be seen clearly through the binary editing form of UE.

//////////////////
<Base target = "_ Self"/> is the default webpage configuration.
<Base target = "_ blank"/> directly acts on <A>... </a> and affects the onclick = "" function in the Link code.

//////////////////
Very strange problem:

Function $ F (ID)
{
Return document. getelementbyid (ID );
}

$ F (ID) is the input id value. You can obtain the name or ID value on the local Apache server.
However, after the code is uploaded to the remote server, only the id value can be obtained. (Same browser !)

What is the difference between a local server and a remote server ??

//////////////////////////////
MySQL MyISAM engine database. If an exception occurs after cold recovery, restart the MySQL service.
Therefore, it is best to back up and restore MySQL offline after the MySQL service is closed.

//////////////////////////////
The address must contain parameters, especially Chinese characters? C = urlencode (...), then urldecode ($ _ Get ['C'])
Note: UTF-8 encoding, under IIS can, under Windows + Apache can not ??
It is also related to IE settings: (IE8) Advanced -- send UTF-8 URL.

//////////////////////////////
Session [] When the backend uses ajax to call and generate a session, the call may fail because the session file is not generated.

//////////////////////////////
Statement header ("Location: XXX. php"); after turning to, you should also execute the exit statement.
Otherwise, it will be executed at the end of the page (although not visible to the eyes ). That is:
Header ("Location: XXX. php ");
Exit;

//////////////////////////////
Do not rename a webpage in the same website. Otherwise there will be cache in the browser, and it will be messy. Both IE and chorom browsers have encountered this problem.

//////////////////////////////
The smarty template file cannot be named again. Otherwise, there will be a cache on the server, resulting in confusion.

////////////////////////////////////
A connected href = "javascript: HanShu ();" and jquery click events can be triggered at the same time, but sometimes only one event is triggered, Which is unstable.
Therefore, do not use JS functions and jquery click events at the same time in a link!

/////////////////////////////////
<Select name = "newgroupid">
<Optgroup label = "member user group">
<Option value = "10" selected> getting started </option>
</Optgroup>
<Optgroup label = "Custom User Group">
<Option value = "20"> QQ visitors </option>
</Optgroup>
<Optgroup label = "custom management group">
<Option value = "16"> intern moderator </option>
<Option value = "17"> website editing </option>
<Option value = "19"> reviewer </option>
</Optgroup> <optgroup label = "system user group"> <option value = "2"> super moderator </option>
<Option value = "3"> moderator </option>
<Option value = "4"> banned </option>
<Option value = "8"> waiting for member verification </option>
</Optgroup> </SELECT>

//////////////////////////////////////// /////////
MySQL string field length and number of Chinese characters:
Utf8 encoded field. The length of the field is the same as the number of saved Chinese characters. For example, if the field length is 6, six Chinese characters can be saved, instead of three.

Zhang Qing (mesh), Weibo: http://t.qq.com/zhangking
From mesh horizon: http://blog.why100000.com
Why 100,000 computer learning networks: http://www.why100000.com

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.