PHP 01 1-6 PHP PHP HTML HTML PHP CSSJavaScript PHP PHP 1-6-1 PHP HTML PHP HTML 1. Notepad++ \ch01\hello.php 01:<!doctype html> 02:<html> 03: <head> 04: <meta charset="utf-8"> 05: <title> PHP </title> 06: </head> 07: <body> 08: <?php 09: echo("hello World!"); PHP 10: phpinfo(); 11:?> 12: </body> 13:</html> HTML HTML 03 ~ 06HTML 04 UTF-8 05 PHP 07 ~ 12HTML 1-23
08 ~ 11PHP 0811 <?php?> PHP <?php?> 09 PHP echo() "Hello World!" PHP (;) 10 PHP phpinfo() PHP PHP Apache MySQL ODBC 2. NotePad++ [] \ [] [] \ [ ] [] UTF-8 BOM hello.php ch01 C:\AppServ\www\ch01 ( [] [ UTF-8 ( BOM)]) 1. ch01 C:\AppServ\www\ch01 3. hello (.php) 4. [] 2. PHP 1-24
PHP 01 3. http://localhost/ch01/hello.php [Enter] 0910 <?php?> PHP <?php?> <??> <??> PHP php.ini short_open_tag on <??> <?php?> XML <script language="php"></script> HTML PHP JavaScript JavaScript <script language="javascript"></script> <% %> ASP ASP PHP <% %> PHP 1-25
1-6-2 PHP PHP 1. PHP NotePad++ PHP UTF-8 BOM demo.inc ch01 ( C:\AppServ\www\ch01) \ch01\demo.inc <?php echo("hello World!"); phpinfo();?> 2. PHP NotePad++ UTF-8 BOM hello2.php ch01 PHP include_once() PHP \ch01\hello2.php <!doctype html> <html> <head> <meta charset="utf-8"> <title> PHP </title> </head> <body> <?php include_once("demo.inc");?> </body> </html> 3. http://localhost/ch01/hello2.php [Enter] 1-26
PHP 01 PHP PHP include("/path/filename") require("/path/filename") include_once("/path/filename") require_once("/path/filename") include() include_once() (warning) require() require_once() (fatal error) include_once() require_once() PHP PHP (fatal error) include() require() PHP 1-27
PHP echo() HTML 09 echo() Hello World! <h1><b> <i> HTML 1 \ch01\hello3.php 01:<!doctype html> 02:<html> 03: <head> 04: <meta charset="utf-8"> 05: <title> PHP </title> 06: </head> 07: <body> 08: <?php 09: echo("<h1><b><i>hello World!</i></b></h1>"); 10:?> 11: </body> 12:</html> 1-28
PHP 01 1-7 PHP PHP (program) (statement) (reserved word) (keyword) PHP PHP function PHP function (special character)php ({ }) (;) ($) /* */ (identifier) mynamemyaddress PHP (function) (flow control) (class) PHP HTML PHP definefunctionifelsedo forwhile $myname $myname N n if IF if 1-29
PHP $x = 10; $x = 10; $x = 10; PHP (;) echo ("Hello World!"); PHP // # // # PHP /* */ /* */ /* xxxxx /* */ */ HTML <!-- --> PHP 1-30
PHP 01 PHP PHP and or xor FILE exception php_user_filter LINE array () as break case cfunction class const continue declare default die () do echo () else elseif empty () enddeclare endfor endforeach endif endswitch endwhile eval () exit () extends for foreach function global if include () include_once () isset () list () new old_function print () require () require_once () return () static switch unset () use var while FUNCTION CLASS METHOD 1-31
15 C H A P T E R
15-1 Google API Google API Google Google API Google Maps API Google Maps API Google AndroidAndroid Android SDK API Android Google Calendar API Google Toolbar API API Google YouTube API API YouTube Google Earth API Google Earth JavaScript API Google Earth (3D ) 3D KML 3D Google AJAX Search API API Google Google API Google Maps API Google Maps Google API Google Developers (https://developers.google.com/) 15-2
Google 15 15-2 Google Maps Google Maps API Google Maps PC 11 jquery Mobile 1. 2. () 3. Google () 15-3
() [] ()() () () 15-4
Google 15 Google Google Maps API <\ch15\farm.php> [] <showmap.php> <\ch15\showmap.php> Google Maps API \ch15\farm.php 01:<!doctype html> 02:<html> 03: <head> 04: <meta charset="utf-8"> 05: </head> 06: <body> 07: <?php 08: $farm_address=array(' 131-1 ', 09: ' 233 ', 10: ' 130 ', 11: ' 23 '); 12:?> 13: <form method="post" action="showmap.php"> 14: <input type="radio" name="farm" value="<?php echo $farm_address[0];?>" checked> <br> 15: <input type="radio" name="farm" value="<?php echo $farm_address[1];?>"> <br> 16: <input type="radio" name="farm" value="<?php echo $farm_address[2];?>"> <br> 17: <input type="radio" name="farm" value="<?php echo $farm_address[3];?>"> <br> 18: <input type="submit" value=""> 19: </form> 20: </body> 21:</html> 15-5
08 ~ 11 farm_address MySQL 13 ~ 19 [] 13 action showmap.php [] showmap.php 14 ~17 value \ch15\showmap.php ( 1/2) 01:<!doctype html> 02: <html> 03: <head> 04: <meta charset="utf-8"> 05: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> 06: </script> 07: <script type="text/javascript"> 08: var geocoder; 09: var map; 10: 11: function initialize() 12: { 13: geocoder = new google.maps.geocoder(); 14: var latlng = new google.maps.latlng(0, 0); 15: var myoptions = {zoom:10, center:latlng, maptypeid:google.maps.maptypeid.roadmap}; 16: map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); 17: codeaddress(); 18: } 19: 20: function codeaddress() 21: { 22: var address = document.getelementbyid("address").value; 23: if (geocoder) 24: { 25: geocoder.geocode({'address': address}, function(results, status) 15-6
Google 15 \ch15\showmap.php ( 2/2) 26: { 27: if (status == google.maps.geocoderstatus.ok) 28: { 29: map.setcenter(results[0].geometry.location); 30: var marker = new google.maps.marker({map:map,position:results[0].geometry.location}); 31: } 32: else 33: { 34: alert("" + status); 35: } 36: }); 37: } 38: } 39: </script> 40: </head> 41: <body onload="initialize()"> 42: <input type="hidden" id="address" value="<?php echo $_POST["farm"];?>"> 43: <div id="map_canvas" style="width:500px; height:500px;"></div> 44: <a href="farm.php"></a> 45: </body> 46:</html> 0506 Google Maps API API JavaScript Google Maps API sensor ( GPS ) sensor=false 11 ~ 18 initialize() codeaddress() 13 google.maps.geocoder geocoder 22.638095 120.325699 15-7
14 google.maps.latlng latlng (0, 0) 15 myoptions 10 latlng 2D 16 google.maps.map map HTML id "map_canvas" 43 <div> 17 codeaddress() 20 ~ 38 codeaddress() 22 marker 41 <body> onload initialize() 42 id "address"value <farm.php> 22 43 <div> id "map_canvas" 500 500 500px 100% 44 <farm.php> 15-8