LoginSignup
1
0

More than 5 years have passed since last update.

シングルクォート’’とダブルクォート””の違いは囲まれた変数の扱い

Posted at

エラーにはまってしまったので
自戒を込めて。

シングルクォートの場合、変数は文字列扱いに

シングルクォートの場合は、囲まれた変数は文字列扱いになってしまいます。

<?php
$getId = 3;
echo '$getId'
?>

この場合出力は

$getId

となってしまいます。

ダブルクォートの場合、変数は変数として扱われる

<?php
$getId = 3;
echo "$getId"
?>

ダブルクォートで、囲むことで

3

と表示させることができます。

1
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
1
0