0
私はこのようなPHPファイルを持っています。PHPファイルの行数と行数(行あたりの長さ)
Line | Length of Line
1 2 3 4 5 6 7 8 9
1 | < ? php
2 |
3 | $g r a d e = 5;
4 |
5 | ? >
どのようにカウントするかこのファイルの各行の総ライン数と長さは?
私はこのようなPHPファイルを持っています。PHPファイルの行数と行数(行あたりの長さ)
Line | Length of Line
1 2 3 4 5 6 7 8 9
1 | < ? php
2 |
3 | $g r a d e = 5;
4 |
5 | ? >
どのようにカウントするかこのファイルの各行の総ライン数と長さは?
このスタック応答は部分的にあなたの質問に:https://stackoverflow.com/a/13246630/6535806、ちょうど$line
のル長さを取得するにはしばらく必要があります。コードは次のようになります:
$handle = fopen("filename.extention", "r");
// if the file exist
if ($handle) {
// for each line
while (($line = fgets($handle)) !== false) {
// write the length of the line
echo strlen($line).'<br />';
}
// then we close the file opened
fclose($handle);
} else {
// error opening the file.
}