When learning PHP, you may encounter PHP string interception problem, here will introduce the PHP string interception function problem resolution, here to share with you. PHP itself is a simple and powerful language. The PHP language has core features such as powerful string and array processing capabilities, while greatly improving the support for object-oriented programming (PHP5 and above).
By using standard and optional extensions, PHP applications can connect more than 10 databases such as MySQL or Oracle, draw, create PDF files, and create parsing XML files. You can also use the C language to write your own PHP extension module. For example, provide an interface function for PHP in a code base that already exists. You can also run PHP under Windows, use COM to control other Windows applications such as Word and Excel, or use ODBC to connect to a database. At home, PHP once and Microsoft's ASP, is commonly used in network programming language.
ASP3.0 now has been abandoned by Microsoft, no longer updated, perhaps some people will think: PHP should be a fast-dying thing, right? However, contrary to the fact, PHP not only in the rapid development, the ASP far behind, and gradually become the Internet is now the most widely used, the most popular language. Let's use PHP as a powerful language to solve this problem.
PHP string intercept function code:
- PHP
- Functionget_substr ($string, $start=' 0 ', $length= '' )
- {
- $ Start = (int) $start;
- $ length = (int) $length;
- $ I = 0 ;
- if (! $string)
- {
- Return
- }
- if ($start>=0)
- {
- While ($i<$start)
- {
- if (Ord ($string [$i])>127)
- {
- $ I = $i +2;
- }
- Else
- {
- $i + +;
- }
- }
- $ Start = $i;
- if ($length= = ")
- {
- Returnsubstr ($string, $start);
- }
- ElseIf ($length>0)
- {
- $ End = $start + $length;
- While ($i<$end)
- {
- if (Ord ($string [$i])>127)
- {
- $ I = $i +2;
- }
- Else
- {
- $i + +;
- }
- }
- if ($end! = $i-1)
- {
- $ End = $i;
- }
- Else
- {
- $end--;
- }
- $ length = $end-$start;
- Returnsubstr ($string, $start, $length);
- }
- ElseIf ($length==0)
- {
- Return
- }
- Else
- {
- $ length = strlen ($string)-abs ($length)-$start;
- Returnget_substr ($string, $start, $length);
- }
- }
- Else
- {
- $ Start = strlen ($string)-abs ($start);
- Returnget_substr ($string, $start, $length);
- }
- }
- ?>
http://www.bkjia.com/PHPjc/446451.html www.bkjia.com true http://www.bkjia.com/PHPjc/446451.html techarticle When learning PHP, you may encounter PHP string interception problem, here will introduce the PHP string interception function problem resolution, here to share with you. PHP itself is a ...