■環境・Windows10 ・XAMPP 8.0.6 ・PHP Version 8.0.6 ■PHPでパーセンテージを計算する関数を定義するでは、PHPでパーセンテージを計算する関数を定義してみます。 ■コード<html lang="ja"> <head> <title>phpでパーセンテージを計算する</title> </head> <body> <?php function get_percentage($percentage,$overall) { $percent = $percentage / $overall; return number_format($percent * 100,2).'%';; } echo get_percentage(10,100); ?> </body> </html>今回は、get_percentageという名前の関数(function)を定義しま
![PHPでパーセンテージを計算する関数を定義する](https://cdn-ak-scissors.b.st-hatena.com/image/square/b0e6c97966e87a40b9ffc727d8131acbff631a61/height=288;version=1;width=512/https%3A%2F%2Flaboratory.kazuuu.net%2Fwp-content%2Fuploads%2F2021%2F07%2FL.png)