LoginSignup
2
0

More than 5 years have passed since last update.

PHP Manual 読書会(2回目)(型)

Posted at

PHPに慣れる為に週1ぐらいで更新していきます。PHP Manualを読んで実験して行きます。

前回: PHP Manual 読書会(1回目)(PHPタグ-コメント)

導入

4 種類のスカラー型

<?php

# 1. 論理値 (boolean)
$bool = TRUE;
$bool = FALSE;

# 2. 整数 (integer)
$int = 1;

# 3. 浮動小数点数
$float = 12.33333;

# 4. 文字列 (string)
$str = "hello";

4 種類の複合型

# 1. 配列 (array)
$ary = array(1,2)

# 2. オブジェクト (object)
class hoge
{
  function run()
  {
    echo "hoge\n";
  }
}

$obj = new hoge;

# 3. callable
function callback()
{
  echo "callback\n";
}

$cb = "callback";
$cb();

# 4. iterable
# http://php.net/manual/ja/language.types.iterable.php
# http://php.net/manual/ja/language.generators.syntax.php
# 関連箇所が多いのでそのときまで置きます

2 種類の特別な型

# 1. リソース (resource)
## http://php.net/manual/ja/resource.php

$fp = fopen("aaaaa", "w");
echo get_resource_type($fp) . "\n";


# 2. NULL
## is_null() および unset()も参照したほうがいい
## 
$var = NULL;
2
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
2
0