During the past one year of work, all projects have been using ADODB, but its code is bloated and execution efficiency is low, which leads to the need for replacement. Baidu later decided to use PDO. as to why we chose PDO, we will not talk about it
In php, database operations are commonly used. here, code and functions are commonly used in php.
The code is as follows:
$ Db_host = 'hostname is database server ';
$ Db_database = 'database name ';
$ Db_username = 'username ';
$ Db_password =
PHP Cache technology is widely used. some people may not know much about this technology. now we will give you a detailed introduction to the related application skills of PHP Cache technology. In most cases, our website uses databases as the
The implementation code of the class file is automatically generated based on the fields in Mysql. For more information about php, see. Automatically Generate a class file based on the fields in Mysql:
But you need to import:
Require_once./db/ez_
PHP upload is also a common function of php. it mainly focuses on the client and server applications. it is much simpler than asp. I. HTML code for uploading forms
The code is as follows:
Note: 1. action is a new Upload
2. the enctype
PHP is undoubtedly a very powerful server-side scripting language, but its powerful functions are always at risk. in this chapter, you will learn how to use the security mode of PHP to prevent potential risk factors of PHP. [Security mode]
The
If you want to export the data in the database as a CSV file in symfony, try the following:
The code is as follows:
Public function executeRegistrantsToCsv (){
$ Id = $ this-> getRequestParameter ('id ');
$ C = new Criteria ();
$ C-> add
Php checks whether the string is full of Chinese characters or the implementation code that contains Chinese characters. it mainly uses regular expressions to match Chinese characters. I. All judgments are in Chinese.
The code is as follows:
$
At that time, the video length was obtained using a common method on the Internet to obtain the flv video file length. However, this method only supports flv videos, the value obtained from videos in other formats is very poor. at that time, the
Php pictures are uploaded to the storage source code and can be previewed. For more information about php learning, see.
The code is as follows:
Header ("content-Type: text/html; charset = gb2312 ");
$ Uptypes = array ('image/jpg ', // list of
The purpose of using UDFs is to avoid repeated code. 7. 1. standard functions
There are more than 1000 standard functions in the standard php release package. these standard functions are built in the system and can be directly used without user
In PHP, the substr function to capture the last character string will appear garbled, because of the Chinese UTF-8 encoding, each Chinese character occupies 3 bytes, while GB2312 occupies 2 bytes, English occupies 1 byte, the truncation bit is
Our PHP program sometimes needs timed execution. we can use the ignore_user_abort function or place js on the page to help us implement it. However, both methods are unreliable and unstable. We can use the Linux Crontab tool to trigger PHP execution
The network environment is very complex. sometimes we have to prohibit access by some malicious users. There are many ways to prohibit access, one of which is through IP address restrictions, the method provided in this article allows you to add a
You cannot load the mcrypt (external link, English) extension because phpmyadmin time is configured for the customer today. Please check your PHP configuration. The PHP extension mbstring is not found, and you are now using a multi-byte character
Summary of methods to optimize the PHP program. For more information about php learning, see section 1. if a method c ++ an be static, declare it static. speed improvement is by a factor of 4. if a method can be static, it will be declared as static.
This is frequently used for sorting array elements in PHP. it is also available in previous projects. We use PHP native functions such as asortarsort for sorting, I didn't implement it myself, so I would like to summarize the several functions below.
For php Security, use $ to GET the value without escaping the $ _ GET character. For more information, see
The code is as follows:
Function my_addslashes ($ string, $ force = 0 ){
! Defined ('Magic _ QUOTES_GPC ') & define ('Magic _ QUOTES_GPC'
PHP5, using the new unified constructor naming method: __construct (), of course, using the class name is also possible PHP 5 authoritative Programming (PHP 5 Power Programming) PDF http://www.bitsCN.com/books/28207.html
In PHP4, _ construct () is
Mysql_fetch_object () is similar to mssql_fetch_array. only one difference is that an object is returned instead of an array and the field name is used as an attribute. Indirectly, it also means that only the field names can be used for access,
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