Php's simple method for calculating the circumference ratio is original, fontcolor. The simple implementation method for php to calculate the circumference rate is original. fontcolor this article describes the simple implementation method for php to calculate the circumference rate. For your reference, I will share with you the following details: the simple implementation method of php to calculate the circumference is original, fontcolor
This article describes the simple implementation of php to calculate the circumference rate. We will share this with you for your reference. The details are as follows:
In the previous article "C language for circumference rate", we provided a simple calculation method for circumference rate. here, we use the previous code to provide the calculation method for php to calculate the circumference rate. The code is as follows:
<? Php $ t = 1; $ pi = 0; $ n = 1.0; $ s = 1; while (abs ($ t)> 1e-6) {$ pi = $ pi + $ t; $ n = $ n + 2; $ s =-$ s; $ t = $ s/$ n ;} $ pi = $ pi * 4; printf ("pi = % 10.6f", $ pi);?>
Calculation result:
Pi = 1, 3.141591
Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming and increase the readability of the code:
Php code online formatting and beautification tools:
Http://tools.jb51.net/code/phpformat
In addition, because php belongs to the C language style, the following tool can also format php code:
C language style/HTML/CSS/json code formatting and beautification tools:
Http://tools.jb51.net/code/ccode_html_css_json