戻る

複合演算子

JavaScript

<meta http-equiv="Content-Type" content="text/html">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
var x = 10;

x += 3;

console.log(x);

x -= 3;

console.log(x);

x *= 3;

console.log(x);

x /= 3;

console.log(x);

x %= 3;

console.log(x);
</script>

13
10
30
10
1

<meta http-equiv="Content-Type" content="text/html">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript"> 
var shiritori = "りんご" + "-" + "ゴリラ" + "ラッパ" + "-" + "パイナップル";
 
shiritori += "-" + "ルビー";
shiritori += "-" + "ビーズ";
shiritori += "-" + "ズッキーニ";
 
console.log(shiritori);
</script>

りんご-ゴリララッパ-パイナップル-ルビー-ビーズ-ズッキーニ

PHP

<?php
header("Content-type: text/plain; charset=utf-8");

$x = 10;

$x += 3;

var_dump($x);

$x -= 3;

var_dump($x);

$x *= 3;

var_dump($x);

$x /= 3;

var_dump($x);

$x %= 3;

var_dump($x);
?>

int(13)
int(10)
int(30)
int(10)
int(1)

<?php
header("Content-type: text/plain; charset=utf-8");

$shiritori = "りんご" . "-" . "ゴリラ" . "ラッパ" . "-" . "パイナップル";

$shiritori .= "-" . "ルビー";
$shiritori .= "-" . "ビーズ";
$shiritori .= "-" . "ズッキーニ";

var_dump($shiritori);
?>

string(83) "りんご-ゴリララッパ-パイナップル-ルビー-ビーズ-ズッキーニ"

inserted by FC2 system