Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下のPHPページ
<?php $a = "World"; function say() { echo $a; } ?> Hello, <?php say(); ?>
次のエラーで失敗します:
Undefined variable: a in test.php on line 5
誰かが理由を説明してもらえますか?これを修正する最善の方法は何ですか?
関数内で変数をグローバルとして定義する必要があります
<?php $a = "World"; function say() { global $a; echo $a; } say(); ?>