Using fonts in PHP

Source: Internet
Author: User
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 of knowledge missed from many PHP books. The author collects and clears some important points based on his development experience. 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 of knowledge missed from 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 convert a PHP function from 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'; // 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 can I use PHP to output control functions?

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, especially when your script has output information, you need to send the file header and compile and process the output information. The output control function does not affect the header information sent by the application 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 ();
?>
This program should output
Hello world

However, after the output control function is specified, the output becomes
Hello php

In the above example, the output content of the application echo () will be retained in the output buffer until ob_end_flush () is called or the script stops running, then, the output information is processed by the custom processing function (replacing the strings) and the result is returned.

Coherent function clarification:

Void ob_start ([string output_callback])-open the output buffer

All output information is not directly sent to the browser, but stored in the output buffer. the optional callback function is used to process output information.

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.