PHP-PHP Tutorial

Source: Internet
Author: User
In PHP, the font is used to explain the issue. Summary: many friends are confused about the traditional and simplified versions of the website. how can this problem be achieved? This is also a very important point missed in many PHP books. My summary: many of my friends are confused about the traditional and simplified versions of the website. how can this problem be achieved? This is also a very important point missed in many PHP books. I collected and sorted out some key points and questions based on my development experience and shared them with you!

How can I use PHP functions that convert traditional Chinese to simplified Chinese?

We define a big5togb function to implement this conversion:

Function big5togb ($ code)
{
// The parameter $ code is a string of the big5 code.
Include "data_big5.php"; // file containing big5 data
$ Output = "";
$ Length = strlen ($ code); // Obtain the string length.
$ Code = strtok ($ code ,"");
$ Idx = 0;
While ($ idx <$ length)
{
$ TmpStr = $ code [$ idx]. $ code [$ idx 1];

If (isbig5 ($ tmpStr) // you can determine whether the code is big5.
{
...... // If it is a big5 code, convert it and output it
}
Else
{
$ Output. = $ code [$ idx]; // output directly if it is not a big5 code
}
$ Idx;
}
Return ($ output );
}

How can I use PHP functions that convert simplified Chinese to traditional Chinese?

How can I use PHP to convert simplified Chinese to traditional Chinese?

We define a big5togb function to implement this conversion:

Function gbtobig5 ($ code)
{
Include "data_gb.php"; // a data file containing a gb code
$ Output = "";
$ Length = strlen ($ code );
$ Code = strtok ($ code ,"");
$ Idx = 0;
While ($ idx <$ length)
{
$ TmpStr = $ code [$ idx]. $ code [$ idx 1];

If (isgb ($ tmpStr) // Determine whether the code is gb
{
...... // If it is output after gb code conversion
}
Else
{
$ Output. = $ code [$ idx]; // output directly if it is not a gb code
}
$ Idx;
}
Return ($ output );
}
In simplified and traditional Chinese conversion, how does one apply the PHP output control function?

What is the PHP output control function?

The PHP output information control function allows you to control the output content of your script, which can be used in many different situations, this is especially true when the file header needs to be sent after your script has output information and where the output information needs to be edited. The output control function does not affect the header information sent using header () or setcookie (). it only applies to data blocks similar to echo (), print (), and PHP code.

Example 1. control output

Test. php
Function test ($ str ){
Return str_replace ("world", "php", $ str );
}
Ob_start ("test ");
Echo "hello world ";
Ob_end_flush ();
?>

Why? This is also a very important point missed in many PHP books. Author...

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.