不属于 if/function 等的代码块的目的是什么

What is the purpose of a code block that isn't part of an if/function etc

例如

<?php

echo "hello word";

$test = 1;

{

//sample php code inside code block

}

?>

为什么示例 php 代码在该代码块中。是否纯粹将其内部定义的任何变量保留在代码块的范围内,以免代码块外部的变量被覆盖?

它很可能只是为了可读性,因为它不会创建新的变量范围或类似的东西。同样来自 manual:

[...]Statements usually end with a semicolon. In addition, statements can be grouped into a statement-group by encapsulating a group of statements with curly braces. A statement-group is a statement by itself as well. The various statement types are described in this chapter.