Example of a truncated use of string lengths in PHP

Source: Internet
Author: User
This article describes the use of string length interception in PHP. Share to everyone for your reference, as follows:

PHP provides a lot of usage functions, where the Intercept function of the string is no exception, and the function is very powerful.

<?php//file encoding format for utf-8$str= ' on the park boat, there's a pretty girl, if something happens in the middle of the lake ... '; Echo mb_substr ($str, 0,7, ' UTF-8 ');//Set the encoding format of the display string// Output ' on the park ship, there's ' Echo mb_substr ($str, 3,7, ' UTF-8 ');//Here Set the encoding format of the display string//output ' on board, there's a drift '?>

Here the coding format must be noted that improper handling may be garbled.

I hope this article is helpful to you in PHP programming.

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.