Code: <HTML>
<Head>
<Title> test </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
</Head>
<? PHP
$ A = 'dir C: '; // note: the key on the left of keyboard 1 is used to output information about drive C.
Echo $;
?>
<Body> </body>
</Html>
Symptom: All Chinese characters after running are garbled, but they are displayed normally in the source file.
Solution: Set <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
The UTF-8 in is changed to gb2312 and the display is normal. In case of garbled characters, do not change the encoding mode of the browser to see if it is normal. If it is normal, change the webpage to the corresponding encoding mode.
Or modify the PHP Code as follows:
<? PHP
$ A = 'dir C :';
$ B = mb_convert_encoding ($ A, 'utf8', 'gb2312 ');
Echo $ B;
?>
This problem can also be solved by converting the encoding before the output.
About _ file _: (Note: there are two underlines. It is easy for beginners to see the error. As a result, use of undefined constant _ file _-assumed '_ file _' is incorrect, and garbled characters appear .)
Explanation:The complete file path and file name (including the suffix ). If it is used in a include file, the include file name is returned. Starting from PhP 4.0.2, __file _ always contains an absolute path, while earlier versions sometimes contain a relative path.
String dirname (string path)
Explanation:Returns a string containing a full path pointing to a file. This function returns the directory name after removing the file name (including the suffix.
Note:In Windows, both slash (/) and backslash (/) can be used as Directory separators. It is a slash (/) in other environments (/).
What if we use dirname for nesting?
Dirname (_ file __));
Assume that _ file _ Is/wwwhome/web/config. php.
The above method output is/wwwhome/Web
Dirname (_ file _); the directory name at the top of the file is obtained.
Dirname (_ file _); the directory name of the file's layer is obtained.
Summary: As we all know, after entering dir in DOS, the folder list and file list will be listed. If the parameter in dirname function is the folder name, it will also be processed. that is to say, you can use this function to obtain the upper-level directories of the current directory.