Php obtains the number regular expression in the string.

The filter_sanitize_number_int filter deletes all invalid characters in the number.This filter allows all numbers and + -.*/$ Number = "5-2 + 3 pp ";Var_dump (filter_var ($ number, filter_sanitize_number_int ));/*Verification Number: ^ [0-9] *

Regular functions are often used in php development.

$ Temp [0] = "abc ";$ Temp [1] = 123;$ Temp [2] = "us .";$ Temp [3] = 5;$ Temp [4] = 58;$ Temp [5] = "cs ";// The code above defines an array with both numbers and stringsEcho "the contents of the array temp are :";Echo " ";// Output array content

Php searches for the number of words in a string

*/$ Str = "hello world"; // define a string$ Result = str_word_count ($ str); // you can specify the number of words.Echo $ result; // output resultEcho " ";$ Result = str_word_count ($ str, 1); // returns an arrayPrint_r ($ result); // output

Key functions of php array searching

$ Crud = array ('China | China | ', 'kelon | lerke | sb', 'sesscxx ');$ Crud = join ('|', $ crud );$ Crud = str_replace ('|', '|', $ crud );$ Pat = "/({$ crud})/I ";$ Txt = 'I know China, who are you sdfex !! ';Preg_match/* _ all */($ pat, $ txt, $

Php addslashes SQL anti-injection function

// The parameter 'A. Z' defines that all uppercase and lowercase letters are escaped.Echo addcslashes ('foo [] ', 'A. Z'); // output: foo []//$ Str = "is your name o 'Reilly? "; // Define a string, including characters to be escapedEcho addslashes ($

Current next reset function in php

$ Array = array ('step one', 'step two', 'step three ', 'step four'); // defines an arrayEcho current ($ array). " n"; // returns the first element of the array.Next ($ array); // The array pointer moves one bit behindNext ($ array); // The array

Commonly used array operations in php array split times key-name difference set

//$ Array = array (, =>, 3 => 13); // create an arrayPrint_r ($ array); // outputs the array content//$ A = array ('green', 'red', 'yellow'); // defines the first array.$ B = array ('avcado', 'apple', 'bana'); // defines the second array.$ C = array_

A php second-level linkage with a database

/*************************************** ******************************************* Email: njj@nuc.edu.cn *************** ******** Date: 2004/10/02 ******************* ********* Reserve the copyright information when you reprint it *****************

PHP object-oriented programming

The concept of object-oriented programming:Different authors may have different ideas, but an OOP language must have the following aspects:Abstract data types and information encapsulationInheritancePolymorphismIn PHP, classes are encapsulated:Class

Php Chinese processing functions

The best method is to use the multi-byte processing function provided by php to process Chinese characters.

Echo " ______________________ ";$ String = "242432 objection: 456, which is equivalent to 7890abc in a wide range of embassy places ";$ Mb_strlen = mb_strlen ($ string );$ Len = 20;Echo $ string. " ";Echo "Total length:". ($ mb_strlen + 1). "

Function of PHP to read the link of a site

Principle: read the source files of a website and analyze the source code using regular expressions to obtain all links./********** Qiushuiwuhen (2002-5-20 )***********/If (empty ($ url) $ url = "http://www.111cn.net/expert/"; // Set url$ Site =

Use PHP to upload images to the database

Today we will teach you how to upload images to the MYSQL database using PHP. In this tutorial, we need to create three php files:Readdir. php-code for storing images in the databaseImage. php-code for displaying the actual imageView. php-show how

Five basic PHP operations on text databases

PHP implements five basic operations on text databases: data display, addition, modification, deletion, and query.I used a message book program as an example to illustrate how PHP can display, add, modify, delete, and query data in a text

PHP operators for PHP learning

PHP operatorsNext, let's take a look at the arithmetic, string, logic, comparison, and other operators of PHP3.1. Arithmetic operators+: $ A $ B plus $ a plus $ B-: $ a-$ B minus $ a minus $ B *: $ a * $ B multiply $ a by $ B /: $ a/$ B except $ a

Real-time PHP implementation

Several effective methods for php to get the file suffix

Use pathinfo functions The code is as follows:Copy code Function extend_2 ($ file_name){$ Extend = pathinfo ($ file_name );$ Extend = strtolower ($ extend ["extension"]);Return $ extend;} Definition and usageThe pathinfo () function returns the

Php process control statement

  The code is as follows:Copy code Switch (variable ){Case value1:Statement1;Break;Case value2:...Default:Defulat statement;} The switch statement is compared with the value in case based on the value of variable. If the value is not equal,

Php list function usage

Note: list () can only be used as an array of numeric indexes. It is assumed that the numeric index starts from 0.Example 1. list () example The code is as follows:Copy code  $ Info = array ('Coffee ', 'Brown', 'Caffeine '); // Listing all the

Php determines if it is an ajax request

1. Pass the _ GET parameter to determine the webpage request.The url is passed as follows: *******. php? AjaxPhp's judgment:If (isset ($ _ GET ['Ajax ']) {... This is an ajax request, and then...}Else {... This is not an ajax request, and

Total Pages: 12780 1 .... 8774 8775 8776 8777 8778 .... 12780 Go to: GO

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.