PHP is quickly promoted by its ease of use, but ease of use is not to say that it can be used, in fact many programmers use it easy to set up a Web application system, but how many people carefully consider their code, whether easy to maintain,
1,php Connection Database
$dbhost = ' localhost ';
$dbuser = ' root '; Your MySQL username
$dbpass = ' 123456 '; your MySQL password.
$dbname = ' data '; The name of your MySQL library
Connecting to a local database
$GLOBALS ["conn"] =
GZIP compression transmission can more effectively save bandwidth flow. He first compresses the text into. GZ and then transmits it to the browser, which is finally extracted by the browser for presentation to the user.
Older browsers may not
Then create the file below, the 1th step to the database, then write and then read.
Copy Code code as follows:
?
$mysql _server_name = "localhost";
$mysql _username = "root";
$mysql _password = "";
$mysql _database = "db";
Grab IP
Contains a counter, a reminder statement, User IP, and their own advertising picture.
Send a header to the browser and say I'm a picture
Header ("Content-type:image/png");
This defines the counter and puts it in a file
$Visited =array ();
if
From the beginning of ASP to PHP, I feel that one of the powerful PHP is the rich built-in functions, such as the previous study of PHP date and time function, read and write the relevant functions of the file are all show that PHP more professional,
Previously encountered such a demand, to the company's services in the map display, and the user's daily access to the coordinates of statistics to see how many users in the range of services can be reached within the radius.
The following is the
Examples are as follows:
function Addfiletozip ($path, $zip) {
$handler =opendir ($path);//Open current folder specified by $path. While
(($filename =readdir ($handler))!==false) {
if ($filename!= "." && $filename!= "...") The {//folder
A very extreme example, a kind of solution to the problem of thinking, recorded, for later use.
How do I remove the suffix of the file default name?
$fileName = A.txt
Two ways:
1: Borrow PHP's Strrchr+trim method: STRRCHR (String1,string2) returns
$db = mysql_connect ("127.0.0.1", "root", "*******") or Die ("cant ' t connect host");
$re = mysql_select_db ("T", $db) or Die ("can ' t Open database");
$sql = "SELECT * FROM News";
$res = mysql_query ($sql);
$row = mysql_num_rows
To give you a simple text manipulation of the class
I wrote it before, but I never had a chance to use it. Text is not as good as database
Data is stored in rows, \ n End, note that the data you entered must end with "\ n", this is a few of the most
This article introduces a simple and interesting login box feature that contains the Gravatar avatar, which is derived from gravatar.com based on the message ID. This article is very basic on the level of CSS implementation and a few lines of jquery
This example describes the PHP custom error usage. Share to everyone for your reference, specific as follows:
The custom error is that you can completely control the error and the content of the message
Setting errors is handled by the functions
Recently our project needs a picture server to store the user avatar, we use ZIMG to process and store the picture, the following brief introduction how to use PHP upload picture to zimg, and obtain the corresponding picture return information
"In general, it is more logical to define the attributes of a class as private."
However, read and assign operations on attributes are very frequent, therefore, in PHP5, two functions "__get ()" and "__set ()" are predefined to get and assign their
In the work item, will encounter some PHP concurrent access to modify a data problem, if this data does not lock, can cause the data error. Below I will analyze a financial payment lock problem. Hope to help you.
1 NO lock mechanism applied
1.1
In the website user data statistics, we often need to obtain the user browser type and the operating system type, this article mainly introduces is based on the PHP to judge the client type, has the need friend to be possible to understand.
Method
This article mainly introduces the PHP binary and the conversion between the strings of teaching, there is a need for friends to understand.
The PHP code is as follows:
'; Echo bintostr ("1110000 1101000 1110000 111001001011101010001100 111
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