Here's how to use it.
For example:
Copy Code code as follows:
function Db_connect ()//Connection database
{
@ $db =mysql_connect (' localhost ', ' root ', ' test ');
if (! $db)
throw new Exception (' failed to connect to database!
Copy Code code as follows:
Format Date
static function FormatDate ($format, $datetime, $week = 0) {
$datetime = $datetime > 3000? $datetime: Strtotime ($datetime);
if ($week) {
$weeknames = [
' Day ',
' One ',
' Two ',
' Three ',
'
How to delete an array element in PHP:
1. Use the Unset () method:
Copy Code code as follows:
$a =array ("Red", "green", "blue", "yellow");
Count ($a); Get 4
unset ($a [1]); Delete a second element
Count ($a); Get 3
echo $a [2
Any PHP developer who uses object-oriented building Web applications needs to master 6 keywords, respectively:
1.Private2.Public3.Protected4.Static5.Final6.Abstract
For the first three keywords, they access relationships within the class as
PHP code$id = Intval ($_get[' id '));
intval(PHP 4, PHP 5)
Intval-get the integer value of a variable
Description
int intval (mixed $var [, int $base = 10])
Returns the integer value of Var, using the specified base for the conversion (the
This article illustrates the CHECKDNSRR usage of PHP functions. Share to everyone for your reference, specific as follows:
That's what it says on the php.net:
(PHP 4, PHP 5)
Checkdnsrr-check DNS Records corresponding to a given the Internet host
Hash table is the core of PHP, which is not too much.
PHP arrays, associative arrays, object properties, function tables, symbol tables, and so on are all used as containers for Hashtable.
PHP hashtable use of the Zipper method to resolve the
This article example needs to verify the content: The mail address, the URL address, the telephone number, the postal code , the verification method share for everybody reference, the concrete content is as follows
1, the verification of the e-mail
This article describes the method for PHP to calculate the maximum minimum latitude and longitude of 4 corners within 3 km of the current coordinates. Share to everyone for your reference, specific as follows:
$LNG, $lat latitude and longitude
Come to the conclusion today.
, when the internal method of a class accesses a property that has been declared as const and static, use the self:: $name form. Note The Const attribute's declaration format, const pi=3.14, not const $PI =3.14
PHP Check the mailbox address of a lot of more commonly used to write their own regular, but is a lot of trouble, I have the method of PHP with a check.
Filter_var
Filter_var is a built-in variable filtering method in PHP that provides a number of
Although there are already php_strip_whitespace methods in PHP5 to return the PHP source function after removing comments and spaces, in order to learn, here is a way to provide your own, you can also remove the blanks in the code and comments, the
Let everyone have a more in-depth understanding of cookies and session, and the flexibility of their development work to bring inspiration.
First, the cookie mechanism
Cookies are small pieces of text stored on the local machine by the server and
After the PHP script is named. PHP, the code is placed in the parentheses below:
Echo can print information, similar to printf.
End Each statement with a semicolon;.
PHP supports three kinds of annotation methods:
In PHP to implement the verification code is very convenient, the key point is to master PHP library and the use of session.
Throughout the online PHP generated verification code examples, are all PHP GD Library and session of the combination, and
In PHP set up a session there are many aspects of the package to set the value of the session or directly set the expiration, expiration and expiration date, the following small series to give you a friend to introduce how to use.
Let's take a look
PHP implementation to add a watermark to a picture
Let's take another look. Support to add a watermark to a picture and text in two different ways. The picture supports gif,png,jpg three formats, and the watermark image supports PNG and
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