Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 1
PHP
1 3,000 Web
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 2

•

• ( )

1.
2.
3.
4. PHP
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 3
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 4

•
•

•
•

•
•
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 5


関数
関数
関数 データ
関数
データ
データ
関数
クラスA クラ...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 6

• 1960 Simula

•
•


• ( )

•

...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 7

• class
 PHP class
• (class) (funct...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 8
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 9


• $this
• public

<?php
class Per...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 10


•
 new
– $object = new ();
•
 $...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 11

•

•


URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 12

• public private protected 3
 publ...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 13
private
 Person.php

• $name privat...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 14
 index.php
<?php
require_once('Perso...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 15

•

•


URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 16

• private
• private
 private
•
 p...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 17

•
• __construct
 construct
•

• _...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 18
 Person.php
<?php
class Person // アク...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 19
 index.php
<?php
require_once('Perso...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 20


• User
• Item
• Mail

• : read -...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 21

• save()
• getParameter($name)
• fi...
URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 22
SimpleXML
 SimpleXML
• XML
• RSS
• h...
Upcoming SlideShare
Loading in …5
×

【アシアル塾】PHPオブジェクト指向再入門・第一回クラスとオブジェクト

6,986 views

Published on

PHPプログラミング学習用の資料です。
PHPによるクラスの定義やオブジェクトの生成・アクセサメソッドや命名について言及しています。

Published in: Engineering
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

【アシアル塾】PHPオブジェクト指向再入門・第一回クラスとオブジェクト

  1. 1. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 1 PHP 1 3,000 Web
  2. 2. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 2  •  • ( )  1. 2. 3. 4. PHP
  3. 3. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 3
  4. 4. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 4  • •  • •  • •
  5. 5. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 5   関数 関数 関数 データ 関数 データ データ 関数 クラスA クラスB 関数 関数 データ データ データ 関数 関数 関数 DB処理 メール処理 役 割 分 担 が 明 確
  6. 6. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 6  • 1960 Simula  • •   • ( )  •  objectA objectB objectC objectD
  7. 7. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 7  • class  PHP class • (class) (function)  class –  (class) • •
  8. 8. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 8
  9. 9. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 9   • $this • public  <?php class Person // 人を表すクラス { public $name = ''; // 名前を記憶するプロパティ public function sayHello() // あいさつするメソッド { echo 'こんにちは、' . $this->name . 'です。'; } } Person.php
  10. 10. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 10   •  new – $object = new (); •  $object-> = 'foo'  echo $object-> •  $object-> () <?php require_once('Person.php'); $taro = new Person(); // newでオブジェクトを作成します $taro->name = 'アシアル太郎'; // name属性の値を変更します $taro->sayHello(); // 「こんにちは、アシアル太郎です。」と出力されます index.php
  11. 11. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 11  •  •  
  12. 12. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 12  • public private protected 3  public • $taro = new Person(); • $taro->name = ' '; // public OK  private • $taro = new Person(); • $taro->name = ' '; // private  $taro->setName(' '); // public OK  protected • private •
  13. 13. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 13 private  Person.php  • $name private • $name setName() <?php class Person { private $name = ''; public function setName($name) { $this->name = trim($name); } public function sayHello() { echo 'こんにちは、' . $this->name . 'です。'; } } Person.php
  14. 14. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 14  index.php <?php require_once('Person.php'); $taro = new Person(); $taro->setName('アシアル太郎'); $taro->sayHello(); index.php
  15. 15. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 15  •  •  
  16. 16. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 16  • private • private  private •  public •  private
  17. 17. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 17  • • __construct  construct •  • __destruct() •
  18. 18. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 18  Person.php <?php class Person // アクセス修飾子の例 { private $name = ''; public function __construct($name) { $this->setName($name); } public function __destruct() { echo 'さようなら'; } public function setName($name) { $this->name = trim($name); } public function sayHello() { // あいさつするメソッド (publicなのでどこからでも呼べる) echo 'こんにちは、' . $this->name . 'です。'; } } Person.php
  19. 19. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 19  index.php <?php require_once('Person.php'); $taro = new Person('アシアル太郎'); $hanako = new Person('アシアル花子'); $taro->sayHello(); $hanako->sayHello(); index.php
  20. 20. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 20   • User • Item • Mail  • : read -> CsvFileReader • : control -> OrderController • : manage -> ConnectionManager
  21. 21. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 21  • save() • getParameter($name) • findByUserName($userName)  boolean (true/false) is has • isAvailable() • isDisabled() • hasParameter($name)  • Item isAvailable() • Database connect() • User isLoggedIn()
  22. 22. URL : http://www.asial.co.jp/ Copyright © Asial Corporation. All Rights Reserved. 22 SimpleXML  SimpleXML • XML • RSS • http://php.net/manual/ja/book.simplexml.php  RSS • dump <?php $rss = simplexml_load_file('http://blog.asial.co.jp/rss/rss2.0.php'); // var_dump($rss); // var_dump(get_class_methods($rss)); foreach ($rss->channel->item as $item) { echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8')."<br>¥n"; // var_dump($item->guid->attributes()); }

×