0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPのスコープについて2

0
Posted at

PHPのスコープについてさらに詳しく。

まずは下記のコードを確認。

<?php

$message = "PHP";

function say_hello($message){
    echo "hello".$message;
}


say_hello($message);

出力結果

hello PHP

関数 say_hello の引数が $message となっている。
echoの時点では、$messageにはなんの値も入っていない。

関数の外(下)で、$messageを引数にした関数 say_hello を呼び出すと、

echo "hello".$message;

が実行される(関数の中身が実行される)

関数の外(上側)で、$messageは

$message = "PHP";

と文字列”PHP"が代入されている。

そのため、say_hello($message)の出力結果は上記のようになる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?