タグ

関連タグで絞り込む (0)

  • 関連タグはありません

タグの絞り込みを解除

PROGRAMMINGとProgrammingとPHPに関するItisangoのブックマーク (127)

  • PHP: トレイト - Manual

    トレイト PHP は、コードを再利用するための「トレイト」という仕組みを実装しています。 トレイトは、PHP のような単一継承言語でコードを再利用するための仕組みのひとつです。 トレイトは、単一継承の制約を減らすために作られたもので、 いくつかのメソッド群を異なるクラス階層にある独立したクラスで再利用できるようにします。 トレイトとクラスを組み合わせた構文は複雑さを軽減させてくれ、 多重継承や Mixin に関連するありがちな問題を回避することもできます。 トレイトはクラスと似ていますが、トレイトは単にいくつかの機能をまとめるためだけのものです。 トレイト自身のインスタンスを作成することはできません。 昔ながらの継承に機能を加えて、振る舞いを水平方向で構成できるようになります。 つまり、継承しなくてもクラスのメンバーに追加できるようになります。 <?php trait ezcReflect

    PHP: トレイト - Manual
    Itisango
    Itisango 2023/08/10
    トレイトは、単一継承の制約を減らすために作られたもので、 いくつかのメソッド群を異なるクラス階層にある独立したクラスで再利用できるようにします。
  • PHP: オブジェクト インターフェイス - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: オブジェクト インターフェイス - Manual
    Itisango
    Itisango 2023/08/10
    インターフェイスは、 マジックメソッド を宣言しても問題ありません。注意:コンストラクタ をインターフェイスで宣言できますが、おすすめできません。 インターフェイスを実装するクラスの柔軟性が大きく損なわれる
  • PHP: static キーワード - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: static キーワード - Manual
    Itisango
    Itisango 2023/08/10
    このページでは、static キーワードを使って static メソッド や static プロパティを定義する方法を説明します。 static は、 static 変数 や static な無名関数、そして 遅延静的束縛 にも使えます。
  • PHP: スコープ定義演算子 (::) - Manual

    スコープ定義演算子 (::) スコープ定義演算子 (またの名を Paamayim Nekudotayim)、 平たく言うと「ダブルコロン」は、トークンのひとつです。 定数 static プロパティ、 クラスの static メソッド、 や親クラスのそれにアクセスできます。 さらに、static メソッドやプロパティは 遅延静的束縛 (Late Static Bindings) 経由でオーバーライドできます。 これらの要素をクラス定義の外から参照する際には、 クラスの名前を使用してください。 変数を用いてクラスを参照することも可能です。 変数の値に (self や parent、 static といった) キーワードを指定することはできません。 なぜダブルコロンに Paamayim Nekudotayim という名前をつけたのか、 ちょっと奇妙に感じられるかもしれません。 しかし、Zend

    PHP: スコープ定義演算子 (::) - Manual
    Itisango
    Itisango 2023/08/10
    スコープ定義演算子 (またの名を Paamayim Nekudotayim)、 平たく言うと「ダブルコロン」は、トークンのひとつです。 static, 定数 およびオーバーライドされたクラスのプロパティやメソッドにアクセスすることができます。
  • PHP: オブジェクトの継承 - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: オブジェクトの継承 - Manual
    Itisango
    Itisango 2023/08/10
    オートローディングが有効になっていない限り、 クラスの定義は実際に使うより前になければなりません。 別のクラスを継承したクラスの場合は、 そのクラスより前に親クラスが宣言されていなければなりません。
  • PHP: アクセス権 - Manual

    アクセス権 プロパティ、メソッドまたは (PHP 7.1.0 以降) 定数のアクセス権 (visibility) は、 キーワード: public, protected または private を指定することにより定義できます。 public 宣言されたクラスのメンバーには、どこからでもアクセス可能です。 protected 宣言されたメンバーには、 そのクラス自身、そのクラスを継承したクラス、および親クラスからのみアクセスできます。 private 宣言されたメンバーには、そのメンバーを定義したクラスからのみアクセスできます。 プロパティのアクセス権 クラスのプロパティは、public, private, または protected として定義することができます。 アクセス権を明示的に指定しない場合、 そのプロパティは public として定義されます。 <?php /** * MyCl

    PHP: アクセス権 - Manual
    Itisango
    Itisango 2023/08/10
    クラスメソッドは、public, private, または protected として定義します。アクセス権を明示せずに宣言したメソッドは、 public となります。
  • PHP: コンストラクタとデストラクタ - Manual

    PHP では、開発者がクラスのコンストラクタメソッドを宣言することが できます。コンストラクタメソッドを有するクラスは、新たにオブジェクトが 生成される度にこのメソッドをコールします。これにより、 そのオブジェクトを使用する前に必要な初期化を行うことができます。 注意: 子クラスがコンストラクタを有している場合、親クラスのコンストラクタが 暗黙の内にコールされることはありません。 親クラスのコンストラクタを実行するには、子クラスのコンストラクタの 中で parent::__construct() をコールすることが 必要です。 子クラスでコンストラクタを定義していない場合は、親クラスのコンストラクタを継承します (ただし、private 宣言されている場合は除く)。 これは、通常のクラスメソッドと同様です。 <?php class BaseClass { function __constr

    PHP: コンストラクタとデストラクタ - Manual
    Itisango
    Itisango 2023/08/10
    <?php class MyDestructableClass { function __construct() { print "In constructor\n"; } function __destruct() { print "Destroying " . __CLASS__ . "\n"; } } $obj = new MyDestructableClass();
  • PHP: クラスのオートローディング - Manual

    クラスのオートローディング オブジェクト指向アプリケーションを作成する開発者の多くは、 クラス定義毎に一つのPHPソースファイルを作成します。 最大の問題は、各スクリプトの先頭に、必要な読み込みを行う長いリストを 記述する必要があることです(各クラスについて一つ)。 spl_autoload_register() 関数を使うと、 任意の数のオートローダーを登録でき、 クラスやインターフェイスが定義されていなくても自動的に読み込めるようになります。 オートローダーを登録すれば、PHPがエラーで止まる前にクラスをロードする最後の チャンスが与えられます。 クラスに類似した言語構造は、同じやり方でオートロードできます。 これには、クラス、インターフェイス、トレイト、列挙型が含まれます。 警告 PHP 8.0.0 より前のバージョンでは、 __autoload() 関数でもクラスやインターフェイス

    PHP: クラスのオートローディング - Manual
    Itisango
    Itisango 2023/08/10
    spl_autoload_register() 関数を使うと、 任意の数のオートローダーを登録でき、 クラスやインターフェイスが定義されていなくても自動的に読み込めるようになります。
  • PHP: クラス定数 - Manual

    クラス定数 値が変更できない 定数 をクラス内に定義することができます。 クラス定数のデフォルトのアクセス範囲は public です。 注意: クラス定数は、子クラスで再定義することもできます。 PHP 8.1.0 以降では、final として定義されたクラス定数は、子クラスで再定義できません。 インターフェイスに定数を持たせることもできます。 インターフェイスについてのドキュメント で例を御覧ください。 変数を用いてクラスを参照することも可能です。 変数の値に (self や parent、 static といった) キーワードを指定することはできません。 クラス定数はクラス単位で割り当てられるものです。インスタンス単位ではないことに注意しましょう。 <?php class MyClass { const CONSTANT = 'constant value'; function sho

    PHP: クラス定数 - Manual
    Itisango
    Itisango 2023/08/10
    クラス定数は、子クラスで再定義することもできます。 PHP 8.1.0 以降では、final として定義されたクラス定数は、子クラスで再定義できません。インターフェイスに 定数 を持たせることもできます。
  • PHP: プロパティ - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: プロパティ - Manual
    Itisango
    Itisango 2023/08/10
    static でないプロパティにアクセスするには -> (オブジェクト演算子) を使って $this->property のようにします 。 staticプロパティへのアクセスには :: (ダブルコロン) を使って self::$property のようにします。
  • PHP: クラスの基礎 - Manual

    class 各クラスの定義は、classキーワードで始まり、クラス名が続きます。 そしてその後に波括弧のペアが続き、 その中にはクラスのプロパティとメソッドの定義を記述します。 クラス名には、PHP の予約語 以外でラベルとして有効なあらゆる名前を使用することができます。 PHP 8.4.0 以降では、アンダースコア (_) 1文字のみのクラス名は非推奨となりました。 有効なクラス名は、先頭が文字あるいはアンダースコアで始まり、 その後に任意の数の文字/数字/アンダースコアが続くものです。 正規表現で表すと、 ^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$ のようになります。 クラスの中には、 定数 や 変数 ("プロパティ" といいます) そして関数 ("メソッド" といいます) を含めることができます。

    PHP: クラスの基礎 - Manual
    Itisango
    Itisango 2023/08/10
    クラスにreadonly を指定することができます。 クラスに対して readonly を指定すると、 宣言されている全ての プロパティに対して readonly を指定した ことになり、 かつ 動的なプロパティ の作成を禁止したことになります
  • PHP: ルール - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: ルール - Manual
    Itisango
    Itisango 2023/08/10
    関数名では、単語の間にアンダースコアを使用します。クラスの場合は、 キャメルケース (camelCase) 形式や パスカルケース (PascalCase) 形式を使います。
  • PHP: ユーザーレベルでの命名の手引き - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: ユーザーレベルでの命名の手引き - Manual
    Itisango
    Itisango 2023/08/10
    あなたが書く PHP コード中の識別子によりよい名前をつけるための手引きです。 グローバル名前空間のシンボルを作成するコードでシンボルの名前を決める際には、 以下のガイドラインを考慮することが重要です
  • PHP: はじめに - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: はじめに - Manual
    Itisango
    Itisango 2023/08/10
    機能には アクセス権、 abstract クラスやメソッド、 final クラスやメソッド、 新たな マジックメソッド、 インターフェイス、 オブジェクトのクローン作成 などがあります。
  • PHP: アロー関数 - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: アロー関数 - Manual
    Itisango
    Itisango 2023/08/10
    アロー関数は fn (argument_list) => expr という形で記述します。アロー関数は 無名関数 と同じ機能をサポートしていますが、 親のスコープで使える変数が常に自動で使える点だけが異なります
  • PHP: 無名関数 - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: 無名関数 - Manual
    Itisango
    Itisango 2023/08/10
    無名関数はクロージャとも呼ばれ、 関数名を指定せずに関数を作成できるようにするものです。 callable パラメータとして使う際に便利です。無名関数の実装には Closure クラスを使っています
  • PHP: Manual

    PHP の振る舞いの変更APCu — APC User CacheComponereエラー処理 — エラー処理およびログ記録FFI — Foreign Function InterfaceOPcache出力制御 — 出力バッファリング制御PHP Options/Info — PHP オプションと情報phpdbg — 対話的な PHP デバッガrunkit7uopz — Zend に対するユーザー操作WinCache — PHP 用の Windows キャッシュXhprof — 階層型プロファイラYac音声フォーマットの操作OpenAL — OpenAL 音声バインディング認証サービスRadiusコマンドライン関連Readline圧縮およびアーカイブBzip2LZFPharRar — Rar アーカイブZipZlib — Zlib 圧縮暗号Hash — HASH メッセージダイジェストフレー

    PHP: Manual
    Itisango
    Itisango 2023/08/10
    PHP の振る舞いの変更 APCu — APC User Cache Componere エラー処理 — エラー処理およびログ記録 FFI — Foreign Function Interface OPcache 出力制御 — 出力バッファリング制御 PHP Options/Info — PHP オプションと情報 phpdbg — 対話的な PHP デバ
  • PHP: function_exists - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: function_exists - Manual
  • PHP: 内部(ビルトイン)関数 - Manual

    Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su

    PHP: 内部(ビルトイン)関数 - Manual
    Itisango
    Itisango 2023/08/10
    多くの関数と言語構造を持っています。他にも コンパイル済みの特定のPHP拡張モジュールを必要とする関数があります。 もしコンパイルされていなければ"undefined function(未定義の関数)" として致命的エラーを発する
  • PHP: 可変関数 - Manual

    可変関数 PHP は可変関数(variable functions)の概念をサポートします。 これにより、変数名の後に括弧が付いている場合、その値が何であろうと PHPは、同名の関数を探し実行を試みます。 この機能は、コールバック、関数テーブル等を実装するために使用可能です。 可変関数は、echo, print, isset(), empty(), include, require のような言語構造と組み合わせて使用する ことはできません。これらの言語構造を可変変数として使うには 独自のラッパー関数を使う必要があります。 <?php function foo() { echo "In foo()<br />\n"; } function bar($arg = '') { echo "In bar(); argument was '$arg'.<br />\n"; } // これは、echo

    PHP: 可変関数 - Manual
    Itisango
    Itisango 2023/08/10
    可変関数(variable functions)の概念をサポートします。 変数名の後に括弧が付いている場合、その値が何であろうと PHPは、同名の関数を探し実行を試みます。 コールバック、関数テーブル等を実装するために使用可能です