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.
このコードがあれば
echo $a + 1;
php の戻り値:Notice: Undefined variable: a in...および1
Notice: Undefined variable: a in...
1
これは少し不明確な状況ですよね?が未定義の場合$a(そして$a実際には未定義)、なぜundefined + 1= なの1ですか? 結果もundefined正しいに違いない?あなたの意見を聞くのは興味深いです。
$a
undefined + 1
undefined
存在しない変数のデフォルト値は ですnull。null数値へのキャストは0. 0+ 数字はこの数字です。
null
0
$a + 1 は、php に $a が int 型であると仮定します。int のデフォルト値を未定義にすることはできず、0 です。その場合、0 + 1 = 1 になります。