オープンソースのWeb開発向けスクリプト言語「PHP」の文法を一から学ぶための入門連載「Web業界で働くためのPHP入門」。 今回は、クラスに対して横断的に機能を追加できる「トレイト」について解説します。 「トレイト」とは トレイトは、継承とはまた別の方法でクラスを拡張できる仕組みです。最初に少し概論的な話をしておきましょう。 垂直方向にクラスを拡張する継承の問題点 連載第17回でクラスを拡張できる仕組みとして継承を解説しました。その継承は親クラスを文字通り引き継ぎ、そこに子クラス独自のプロパティやメソッドを追加することで拡張します。例えば、スポーツ選手を表すSportsPlayerクラスがあったとします(リスト1)。 <?php class SportsPlayer { //名前のプロパティ。 private $name; //コンストラクタ。名前プロパティに値をセットする。 publi
PHPデベロップメントチームは3月1日(米国時間)、「PHP: Hypertext Preprocessor」において、脆弱性の修正を目的とした3つのリリースを公開した。PHP 7.0.28およびPHP 5.6.34ではHTTPレスポンスのパース中に発生するスタックオーバーフローの脆弱性の修正のみが取り込まれている。PHP 7.2.3では複数のバグ修正に加え、脆弱性の修正が行われている。 公開された情報は次のとおり。 PHP 7.2.3 Released PHP 7.0.28 Released PHP 5.6.34 Released PHPデベロップメントチームは、該当するバージョンを使用しているすべてのユーザーに対して問題が修正された最新版へアップグレードすることを推奨している。長期的に見るとPHPのシェアは下落する傾向を見せている。しかし、サーバサイドのプログラミング言語として依然とし
この記事はPHP Advent Calendar 2017の2日目です。 ここ最近、本業のほうが死ぬほど忙しく、すっかりブログを書いていなかった@Hirakuです。 だいぶ前のことですが、今年のPHPカンファレンス福岡で例外の話をしてきました。 この時の発表では例外に関する概要が主だったので、例外クラスそのものの設計について補足を書いてみることにします。 例外のある世界観 PHP7ではいくつかのエラーが例外と同じ挙動を示すようになり、エラーではなく例外機構を使う言語に様変わりしました。 例外というのは、かなり侵略性の高い概念であり、例外のある世界では以下の前提に立つことが暗黙のうちに強要されます。 どこでも例外が発生する可能性がある 例外によって中断されても、ソフトウェアが不適切な状態にならないように保証するのは各プログラマの責任(例外安全) たとえば、以下の関数で例外が発生する可能性があ
10月に入社した開発部の澤井です。現在、新人研修を受けています。カルテット開発部では、新人一人に対して教育担当者が二人もつきます。(とても贅沢です) ところで、皆さんはコード設計についてどのような考えをお持ちでしょうか。私は現在、新人研修を通してより良いコード設計について学ぶ日々ですが、残念ながら「これが良いコード設計です」と言えるだけの知識はまだありません。 そこで本エントリーでは、新人研修で取り組んだ問題を例にして、実際に自分のコードがどのように変化していったのかを書くことで、私が新人研修を通して学んだこと、考えたことをお伝えできればと思います。 取り組んだ問題:「群島の宝探し」 これは、教育担当の後藤が作成したオリジナル問題です。大まかなルールは以下のとおりです。 群島はスタートとゴール、およびA島〜E島の5つの島からなる プレイヤーは1回〜複数回サイコロを振り、スタートからゴールを
サンプルサーバーのパケットフィルタは最初は以下の内容で設定し、セキュリティを確保しています。 tcp 22 はプライベートLANからの受信のみ許可 tcp 3306 は 153.127.195.113 のappサーバーだけに公開 tcp 80 は公開 tcp, udp の 32768-61000 はアウトバウンド通信の戻りパケット用に許可 ストリーミングのフラグメントパケットは公開 ip は基本拒否 また IP アドレスを打たずにホスト名でアクセス出来るように /etc/hosts に以下のエントリを追加しました。 153.127.195.113 app 153.127.203.176 db MySQLクライアントで接続して TCP の状態を観察 ここから実際にサーバーを動かして、その挙動を観察していきます。db サーバーに db1 データベースを作成し、アクセスユーザー user1 を追
運営しているサイトにキャッシュをいれたのでその時のメモ。 対象のサイト https://38qa.net/ 1日7000PVくらいなので、負荷も大したことないが、SNSでのシェアなどで一時的にデータベースに負荷がかかって稀に落ちることがある。落ちるのはサーバではなく、データベースのMySQLが多い。そこで、高速化も兼ねて、簡単にできる初歩的なデータベースでの負荷対策を行う。このあたりの知識は詳しくはないので、もしこれを見て同じことをやる場合は、個別に調べてもらった方が良い。 クエリの診断まず、やばそうなクエリがないかを調べる。SHOW STATUSコマンドで調べたところ、Select_full_join、Select_full_range_joinなどのまずい値は0。サイトがオープンソースのシステムを使っているので、さすがにindexの貼り忘れなどの初歩的な問題はなさそうだ。 MySQLの
2017/10/08 PHPカンファレンス2017
Transcript ӡ༻ɺՃ։ൃͮ͠Β ͍PHPΞϓϦέʔγϣ ϯʹະདྷΛ༩͑Δํ๏ VOYAGE GROUP ాத վ (ara_ta3) PHP ΧϯϑΝϨϯε 2017 #phpcon2017_3 ࣗݾհ • VOYAGE GROUP ৽ଔ4 • fluct(ࠂ) -> Zucks(ࠂ) -> HR Tech Studio(ਓࡐ) • ओʹαϙʔλʔζ։ൃ • Twitter(@ara_ta3) • ͖ͳݴޠ • Scala, Go, PHP7.x • Splatoon2 σϚΤ S+0 VOYAGE GROUP VOYAGE GROUP None None • ӡ༻ɺՃ։ൃͮ͠Β͍ΞϓϦέʔγϣϯ ΛͲ͏վળ͍͔ͯ͘͠ • ୈҰาΛͲ͏ͬͯ౿Έग़ͯ͠ະདྷʹ ͔͏͔ ࠓ͍͑ͨ͜ͱ Agenda • ӡ༻ɺՃ։ൃͮ͠Β͍ͱʁ • αϙʔλʔζͷ࣌ͷڥ
。PHPカンファレンス2017での発表資料です。
2. 徳丸浩の自己紹介 • 経歴 – 1985年 京セラ株式会社入社 – 1995年 京セラコミュニケーションシステム株式会社(KCCS)に出向・転籍 – 2008年 KCCS退職、HASHコンサルティング株式会社(現社名:EGセキュアソリューショ ンズ株式会社)設立 • 経験したこと – 京セラ入社当時はCAD、計算幾何学、数値シミュレーションなどを担当 – その後、企業向けパッケージソフトの企画・開発・事業化を担当 – 1999年から、携帯電話向けインフラ、プラットフォームの企画・開発を担当 Webアプリケーションのセキュリティ問題に直面、研究、社内展開、寄稿などを開始 – 2004年にKCCS社内ベンチャーとしてWebアプリケーションセキュリティ事業を立上げ • 現在 – EGセキュアソリューションズ株式会社 代表 https://www.eg-secure.co.jp/ – 独立行
オープンソースのWeb開発向けスクリプト言語「PHP」の文法を一から学ぶための入門連載。最終回は、クラスの論理的な入れ物である名前空間とクラスを自動的に読み込むオートロードを解説します。
This document discusses various ways to customize and extend PHP beyond its typical usage as a templating language. It explores how PHP's opcode cache, extensions, object model, and virtual machine can be leveraged. It also provides examples of PHP's lexer, parser, and how opcodes are generated from PHP code. The document discusses PHP performance and dives into the internals of how PHP works, inc
C#/.NET はサーバーからクライアントまで、そして今となっては iOS / Android などのモバイルでも使える超オールマイティな言語です。たったひとつの言語で一気通貫した開発ができることは、極めて効率的と言えます。 Powered by C# - Microsoft Visual Studio 一方 PHP は Web 向けの言語です。それ以外の用途には基本的に向きません。LAMP 環境を至高と考えている人の中には「銀の弾丸」かのような勘違いをしている人もいるかもしれませんが、あくまでも Web 用。適材適所です。 最近 PHP で困ったこと そんな中、最近業務で前任者が実装した PHP でバッチ処理 をしているコードと対峙することになりました。Web API として実装されており、POST アクセスの先で都度データベースに何万回も insert 文を投げるというものです。Lin
LAMP構成のWebアプリケーション開発では、ストアドプロシージャを全然作っていないなと感じます。私が作っているサービスでは、そんなに入り組んだ処理をしていないだけですけど(^_^;、それでもやっぱり、データベースの主要な機能である、ストアドプロシージャや、ストアドファンクションをPHPから使用する方法は知っておいた方がよいかなと思い、試してみた事をメモします。 PHP(PDO)からストアドプロシージャの実行 MySQLのストアドプロシージャの解説は、「http://dev.mysql.com/doc/refman/5.1/ja/stored-procedures.html」や「http://www.klab.org/media/mysql/index5.html」の記事が非常に参考になりますので、併せてご参照ください。 それでは、早速ストアド本体のサンプルとして、MySQLのDESCRI
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く