Php basic programming FAQ summary this edition of the FAQ summary, limited by space answers may not be detailed enough, need more answers to make full use of the search engine. The content of this post will be updated one after another. We hope to help more new users who need it. if you have any mistakes, please correct them. 1. how can I determine whether php is successfully installed and output related configuration environment parameters of php? Answer: 1. create a php file, for example, File name: phpinfo. php & nbsp; 2. add the php basic programming FAQ in the php file.
Summary of common questions in this version. limited space answers may not be detailed enough. more answers are needed to make full use of the search engine.
The content of this post will be updated one after another. We hope to help more new users who need it. if you have any mistakes, please correct them.
1. how can I determine whether php is successfully installed and output related configuration environment parameters of php?
Answer: 1. create a php file, such as the file name phpinfo. php.
2. add code to the PHP file
3. open the file in the browser, localhost/phpinfo. php
If a detailed document appears normally, the installation is successful. if the above source code is directly output or the download file is not successful.
2. how to enable the php error prompt function? Disabled by default
A: In the php. ini file, change the search field error_reporting to error_reporting = E_ALL.
Display_errors is changed to display_errors = On. if there is # in front of the field, delete this annotator.
You need to restart apache to take effect. you can also add the code error_reporting (E_ALL) in the PHP file );
3. an error message similar to "Notice: Undefined index: xxx in..." is displayed.
A: This is a new change after version 5.3 (if you remember correctly). This is not an error, but a prompt.
The prompt indicates that the variable is used if it is not declared.
The solution can be:
A. disable the error prompt (or modify the error prompt level ). See FAQ 2 modify display_errors = Off
B. add if (issset ($ _ POST ['test']) before assigning values to submitted parameters, for example, $ _ POST ['test '].
Variable prompts can be replaced by initialization value assignment. for example, $ test = '';
4. garbled Chinese characters are output from the database or page, but there is no problem with English and numbers.
A: Generally, this problem is caused by encoding, so keeping all codes consistent is the solution to the problem.
Take gbk as an example
Php file header output header ("Content-Type: text/html; charset = gbk ");
Execute mysql_query ("set names 'gbk'") after connecting to the database in php '");
Set Database/table encoding to gbk
Whether the file encoding check is ANSI
5. how to build a php runtime environment?
A: We will have a detailed post to introduce this aspect. if you are a beginner, we recommend that you use integration.
The installation package to learn, because the php version is relatively large, if you only refer to the online teaching materials, it is easy to cause learning confusion.
Download the complete installation package for the following system and run the installation. for configuration problems, see the official help documentation.
Windows: http://www.apachefriends.org/zh_cn/xampp-windows.html
Http://www.apachefriends.org/zh_cn/xampp-linux.html: Linux
6. why do I use You can.
A: There is a short tag option in php. ini. open short_open_tag = On. remember to delete this annotator if there is # above.
This function is not recommended for individuals. please follow To write the code.
7. What are common php development tools?
A: If you like development tools that seem very professional and feature a wide range of functions
Eclipse zendstudio phpdesinger phpstorm netbeans...
If you like simplicity, the original development tools
Notepad ++ editplus ....
In Linux, there are basically all the Ides listed above, and Vim Gvim is available for simplicity...
8. what is the "flexibility" in the floating point number operation?
A: Warning
Floating point precision
Obviously, a simple decimal score is like 0.1 or 0.7. it cannot be converted to an internal binary format without losing a little precision. This will lead to chaotic results: for example, floor (0.1 + 0.7) * 10) usually returns 7 instead of 8 in expectation, because the internal representation of the result is similar to 7. 9999999999 ....
This is related to the fact that it is impossible to accurately express certain decimal scores with limited digits. For example, decimal 1/3 is changed to 0.3333333 ....
Therefore, never believe that the result of a floating point number is accurate to the last digit, or compare whether the two floating points are equal. If higher precision is required, use any precision mathematical function or gmp function.
9. the UTF8 encoded file session_start (), header (), settcookie () and other functions have an error and the system prompts "headers already sent ".
A: Generally, the UTF-8 encoding editor adds a three-byte BOM code to the file header to identify the UTF-8 encoding format. these three bytes are invisible to the normal file editor, the output is output in HTML first. The above error is prompted when you execute the above function. Solution: Use editplus to clear the BOM Editor and clear the BOM (set to utf8 to clear the BOM.
10. notes for coding mysql and php.
A: I need to remind you of the SET NAMES in mysql 'utf8'; there is no horizontal bar, and the correct php writing is UTF-8, many beginners in this place easy to get mixed puzzled, I hope to pay special attention to this small difference.
------ Solution --------------------
Thank you, Niu Ge.
------ Solution --------------------
Yes .. Niu hasn't had a holiday yet!
------ Solution --------------------
It's good to see this post early.
------ Solution --------------------
I learned how to list all my questions.