SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
序章: PHPとは
■ PHPとは
PHP(Hypertext Pre-processer)は、プログラミング言語の一種で、HTMLの文書内で記
述を行えることが特徴です。
世の中には200種以上のプログラミング言語があると言われていますが、インターネット
が広く普及して以降、PHPは全てのプログラミング言語の中でシェア率ベスト5に入ってお
り、その中でもWebに向いているプログラミング言語の中ではシェア率1位で、世界中で多
くの人が使用しております。
2013年9月 TIOBE発表プログラミング言語ランキング
プログラミング言語

シェア率

1

C

16.975%

2

Java

16.154%

3

C++

8.664%

4

Objective-C

8.561%

5

PHP

6.430%

6

C#

5.564%

7

(Visual)Basic

4.837%

8

Python

3.169%

9

JavaScript

2.015%

10

Transact-SQL

1.997%

Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
■ PHPの使用例
PHPは様々な企業で利用しており、有名なところでFacebook、Yahoo、GREEなどが
PHPを使用しております。
具体的にどのような場面でPHPを利用しているかというと、例えばFacebookの場合、友
達情報や自分の名前など、個人ごとに異なる情報の読み込みから表示、ユーザ認証(ログイ
ン)など、様々なところでPHPを利用し、結果として私達が普段見ているFacebookのページ
となっております。
例) Facebook ユーザ認証ページ
メールアドレスやパスワードを入力しログインボタンを
押した際、PHPで該当するメールアドレスとパスワード
の組み合わせのユーザが存在するか照会し、
存在した場合は該当ユーザのトップページ
存在しなかった場合はエラーページ
を表示している。

Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
例) Facebookユーザページ(一部抜粋)
同じユーザ名が複数箇所に表示されているが、これはPHPを利用して表示している。

Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
■ プログラミング言語(PHP)はなぜ必要か
PHPに限らず、Webページ作成の上でなぜプログラミング言語が必要かというと、表示
する内容を「動的」に変えることにより、よりリッチなWebページ作成が可能となるためで
す。
現在時刻を表示: http://codecamp.lesson.codecamp.jp/date.php

例えばブラウザで「ページを表示した瞬間の時刻」をWebページに表示したいといった
場合、時刻というのは常に変動している動的な値であり、HTMLで現在時刻を表現すること
はできません。
しかし、PHPを代表としたプログラミング言語を利用すると、簡単に現在時刻を表示する
ことができます。
Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
■ PHPを体験(RPG)
まずは実際にPHPを使った動的な動きがあるページを体験して頂きたいと思います。
テキストエディタを利用し、 参照にある内容をコピーしたファイルを作成しましょう。
参照: http://codecamp.lesson.codecamp.jp/RPG_html.txt
ファイル作成が終わったらをFileZillaでファイルアップロードを行った後、Google
Chromeより閲覧してみましょう。
ファイル名: RPG.php
ホスト: 153.122.22.245
アップロード先: /htdocs/RPG.php
URL: http://User名.lesson.codecamp.jp/RPG.php
※User名の部分を自身のUser名に変更

Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
RPGの戦闘画面のようなページが閲覧できたと思いますが、作成したファイルでPHPは
利用しておらず、敵、味方ともに与えるダメージは、「10」で固定されています。

ゲームのようにダメージを固定でなくアクセス毎に変えるためには、表示内容を動的に変
えることができるプログラミング言語(PHP)が必要となります。
ダメージに幅が出るよう、PHPを使い、動的な動きを実現してみましょう。
書き写しで構いませんので、 お手本を参考に先ほどのファイルを改修してみましょう。
※青字の部分が追加又は変更箇所となります。
参照: http://codecamp.lesson.codecamp.jp/RPG_php.html
書き写しが終わったらをFileZillaで RPG.phpファイルを上書きし、Google Chromeより
閲覧してみましょう。
Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
今回PHPを使って、「プレイヤー及び敵の体力設定(HP)」や「プレイヤー名の変更」、
「プレイヤー及び敵の攻撃ダメージ幅の設定」を行えるようにしました。
この中でもダメージ幅は「rand(1, 9);」という記述により、PHPでランダムな数字を毎
回表示するという、非常に分かりやすい「動的」な動きを実現しております。

この場合は
1が最低値
9が最大値
この数値を変えると・・・
Copyright © TribeUniv All Rights Reserved.
序章: PHPとは
■ PHPを体験(ひとこと掲示板)
次に「ユーザ同士のやり取り」があるページを体験して頂きたいと思います。
以下のURLにアクセスし、掲示板に書き込みをしてみましょう。
参照: http://codecamp.lesson.codecamp.jp/bbs.php

この掲示板は、PHPとHTMLの組み合わせ100行で作られています。
参照: http://codecamp.lesson.codecamp.jp/bbs_code.txt

Copyright © TribeUniv All Rights Reserved.

【実践】何も入力しないで送信や、名前を20文字以上入力して送信を試してもらい、PHPで入力値のチェックを行っている
のを知ってもらう。
序章: PHPとは
■ PHP講義の進め方と目標
「PHPを体験」で訳も分からずRPGを作成したり、ひとこと掲示板の中身を見せられた
りで、大変だった方や今後を不安に感じた方もいると思いますが、本講義ではまず、
■ ひとこと掲示板の記述内容(ソースコード)を理解できる
■ ひとこと掲示板を自力で作れる
上記を目標として進めて行きたいと思います。
また、ひとこと掲示板の後には、これを進化させた「Twitterのようなシステム」を作れる
ことを目標とする予定です。
プログラムはスポーツなどと一緒で、ルールを知っているのと実際に行うのはかなり異な
り、実際にコードを書いて体験するのが上達への近道となります。よって、最初の目標とな
るひとこと掲示板以外にも多数の実例やサンプルを交え、可能な限り手を動かし楽しみなが
ら、講義を進めたいと思います。

Copyright © TribeUniv All Rights Reserved.

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

【CodeCamp】教科書サンプル