Learning PHP, MySQL javascript

829 787 0
Learning PHP, MySQL  javascript

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

eb Ap on iti ile Ed es ob h ud M 5t I n c l p s & W Learning PHP, MySQL, & JavaScript WITH JQUERY, CSS & HTML5 Robin Nixon FIFTH EDITION Learning PHP, MySQL & JavaScript With jQuery, CSS & HTML5 Robin Nixon Beijing Boston Farnham Sebastopol Tokyo Learning PHP, MySQL & JavaScript by Robin Nixon Copyright © 2018 Robin Nixon All rights reserved Printed in the United States of America Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://oreilly.com/safari) For more information, contact our corporate/insti‐ tutional sales department: 800-998-9938 or corporate@oreilly.com Editor: Andy Oram Production Editor: Melanie Yarbrough Copyeditor: Rachel Head Proofreader: Rachel Monaghan July 2009: August 2012: June 2014: December 2018: May 2018: Indexer: Judy McConville Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest First Edition Second Edition Third Edition Fourth Edition Fifth Edition Revision History for the Fifth Edition 2018-05-08: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491978917 for release details The O’Reilly logo is a registered trademark of O’Reilly Media, Inc Learning PHP, MySQL & JavaScript, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work Use of the information and instructions contained in this work is at your own risk If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights 978-1-491-97891-7 [M] For Julie Table of Contents Preface xxiii Introduction to Dynamic Web Content HTTP and HTML: Berners-Lee’s Basics The Request/Response Procedure The Benefits of PHP, MySQL, JavaScript, CSS, and HTML5 MariaDB: The MySQL Clone Using PHP Using MySQL Using JavaScript Using CSS And Then There’s HTML5 The Apache Web Server Handling Mobile Devices About Open Source Bringing It All Together Questions 2 6 10 10 11 12 12 13 14 Setting Up a Development Server 17 What Is a WAMP, MAMP, or LAMP? Installing AMPPS on Windows Testing the Installation Accessing the Document Root (Windows) Alternative WAMPs Installing AMPPS on macOS Accessing the Document Root (macOS) Installing a LAMP on Linux Working Remotely 18 18 22 24 25 26 27 28 28 v Logging In Using FTP Using a Program Editor Using an IDE Questions 29 29 30 31 33 Introduction to PHP 35 Incorporating PHP Within HTML This Book’s Examples The Structure of PHP Using Comments Basic Syntax Variables Operators Variable Assignment Multiple-Line Commands Variable Typing Constants Predefined Constants The Difference Between the echo and print Commands Functions Variable Scope Questions 35 37 38 38 39 40 45 48 50 52 53 54 55 55 56 62 Expressions and Control Flow in PHP 63 Expressions TRUE or FALSE? Literals and Variables Operators Operator Precedence Associativity Relational Operators Conditionals The if Statement The else Statement The elseif Statement The switch Statement The ? Operator Looping while Loops while Loops for Loops vi | Table of Contents 63 64 65 66 67 69 70 74 75 76 78 79 82 83 84 86 86 Breaking Out of a Loop The continue Statement Implicit and Explicit Casting PHP Dynamic Linking Dynamic Linking in Action Questions 88 89 90 91 92 93 PHP Functions and Objects 95 PHP Functions Defining a Function Returning a Value Returning an Array Passing Arguments by Reference Returning Global Variables Recap of Variable Scope Including and Requiring Files The include Statement Using include_once Using require and require_once PHP Version Compatibility PHP Objects Terminology Declaring a Class Creating an Object Accessing Objects Cloning Objects Constructors Destructors Writing Methods Declaring Properties Declaring Constants Property and Method Scope Static Methods Static Properties Inheritance Questions 96 97 98 99 100 102 102 103 103 103 104 104 105 106 107 108 108 110 111 111 112 113 113 114 115 116 117 120 PHP Arrays 123 Basic Access Numerically Indexed Arrays Associative Arrays Assignment Using the array Keyword 123 123 125 126 Table of Contents | vii The foreach as Loop Multidimensional Arrays Using Array Functions is_array count sort shuffle explode extract compact reset end Questions 127 129 132 132 132 133 133 133 134 135 136 136 137 Practical PHP 139 Using printf Precision Setting String Padding Using sprintf Date and Time Functions Date Constants Using checkdate File Handling Checking Whether a File Exists Creating a File Reading from Files Copying Files Moving a File Deleting a File Updating Files Locking Files for Multiple Accesses Reading an Entire File Uploading Files System Calls XHTML or HTML5? Questions 139 140 142 143 143 146 146 147 147 147 149 150 150 151 151 153 154 155 161 162 163 Introduction to MySQL 165 MySQL Basics Summary of Database Terms Accessing MySQL via the Command Line Starting the Command-Line Interface viii | Table of Contents 165 166 166 167 escape characters in JavaScript, 319 in PHP, 49, 259 escapeshellcmd function (PHP), 162 event functions and properties (jQuery) blur and focus, 513 click and dblclick, 514 documentation, 512 keypress, 515-517 mouse events, 517-522 passing keyboard interrupts, 517 submit, 522 this keyword, 514 event handling in jQuery, 510 events (JavaScript) attaching to objects in scripts, 489 attaching to other events, 490 exclusive or (xor) logical operator (PHP), 47, 68 exec system call (PHP), 161-162 execution operators (PHP), 66 EXPLAIN command (MySQL), 226 explicit casting (JavaScript), 346 explicit casting (PHP), 90 explode function (PHP), 133 exponentiation (**) operator, in PHP, 45 expressions in JavaScript, 329 in PHP, 63-66 extends keyword (PHP), 117 extract function (PHP), 134 F fade effects, 526 fetch_array method, 242 fetch_assoc method, 239 fgets function (PHP), 149 file handling (PHP) copying files, 150 deleting files, 151 file creation, 147 file pointers and file handles, 151 file_exists function, 147 fopen modes, 148 form data validation, 158 including/requiring files, 103 locking files for multiple accesses, 153 moving files, 150 naming rules, 147 reading files in total, 154 reading from files, 149 sequence of, 148 updating files, 151 uploading files, 155-160 FILE constant, 54 $_FILES array (PHP), 157 $_FILES variable, 61 file_exists function (PHP), 147 file_get_contents (PHP), 154 fillRect method (HTML5), 591 fillText method (HTML5), 602 final keyword (PHP), 120 Flash, 646 flock function (PHP), 153 flow control (JavaScript) conditionals, 339-342 explicit casting, 346 expressions, 329 literals and variables, 330 looping, 342-346 onerror events, 337 operators, 331-336 try catch construct, 338 with statements, 336 flow control (PHP) conditionals, 74-83 dynamic linking in action, 92 dynamic linking in PHP, 91 expressions, 63-66 implicit and explicit casting, 90 looping, 83-90 operators, 66-74 font property (HTML5), 601 fonts fonts and typography, 433 text effects, 470 text styles, 435 web fonts, 472 fopen function (PHP), 148 for loops in JavaScript, 344 in PHP, 86 forEach method (JavaScript), 364 foreach as loops (PHP), 127 form attribute, 285 form data validation, 158 (see also file han‐ dling) form handling autocompleting fields, 283 Index | 785 building forms, 267 checkboxes, 272-274 color selection, 285 date/time pickers, 286 drop-down lists, 276 example program, 280-282 helpful hints, adding, 283 hidden fields, 275 immediate element focus, 283 input image dimensions, 284 interacting with entire element, 277 overriding form settings, 284 radio buttons, 274 required fields, 284 restricting input to numbers/ranges, 285 retrieving submitted data, 269 sanitizing input, 278-280 specifying form to which input applies, 285 specifying min/max input values, 284 stepping through number values, 284 submit button text and graphics, 278 supplying default values, 270 supplying lists, 285 text areas, 271 text boxes, 271 formaction attribute, 284 forward slash (/) /* and */ in multiline comments in PHP, 38 /**/ in CSS comments, 417 // in JavaScript comments, 312 in regular expressions, 378 fread function (PHP), 149 fseek function (PHP), 152 FTP (File Transfer Protocol), 29 FULLTEXT indexes (MySQL), 192, 739-741 FUNCTION constant, 54 functions (JavaScript) creating, 321 defining, 349 returning arrays, 353 returning values, 351 functions (MySQL) benefits of, 206 date functions, 746-751 string functions, 743-746 time functions, 751-752 functions (PHP) advantages of, 95 arguments accepted by, 96 786 | Index array functions, 132-137 basics of, 55 defining, 97 including and requiring files, 103 naming rules, 97 nesting for execution order, 98 passing arguments by reference, 100 purpose of, 95 returning arrays from, 99 returning global variables, 102 returning values from, 98 social networking app example, 676-679 using (calling), 96 variable scope, 102 version compatibility and, 104 function_exists function (PHP), 104 fuzzy character matching, 378 G geolocation, 581-583, 655, 657 $_GET array, 246 GET method (HTTP) asynchronous communication and, 403-406 jQuery and, 555 $_GET variable, 61 getCurrentPosition method, 658 getElementById function C function, 483 enhanced version of, 481 including functions in web pages, 484 O function, 481 S function, 482 getElementsByTagName method, 409 getImageData method (HTML5), 625 get_magic_quotes_gpc function (PHP), 260 get_password method (PHP), 112 Global Positioning System (GPS), 655 global variables in JavaScript, 321 in PHP, 102 in PHP), 59 globalAlpha property (HTML5), 632 globalCompositeOperation property (HTML5), 629 Google Maps, 395, 658, 660 Google web fonts, 473 goto fail bug, 76 gradients, 438-439 GRANT command (MySQL), 174 granted function, 658 graphical effects, 629-632 (see also canvas (HTML)) greater than (>) operator in JavaScript, 318, 334 in PHP, 46, 68, 72 greater than or equal to (>=) operator in JavaScript, 318, 334 in PHP, 46, 68, 72 GROUP BY keyword (MySQL), 202 H height attribute, 284 height method (jQuery), 538 heredoc (

Ngày đăng: 02/01/2020, 10:07

Từ khóa liên quan

Mục lục

  • Copyright

  • Table of Contents

  • Preface

    • Audience

    • Assumptions This Book Makes

    • Organization of This Book

    • Supporting Books

    • Conventions Used in This Book

    • Using Code Examples

    • O’Reilly Safari

    • How to Contact Us

    • Acknowledgments

    • Chapter 1. Introduction to Dynamic Web Content

      • HTTP and HTML: Berners-Lee’s Basics

      • The Request/Response Procedure

      • The Benefits of PHP, MySQL, JavaScript, CSS, and HTML5

        • MariaDB: The MySQL Clone

        • Using PHP

        • Using MySQL

        • Using JavaScript

        • Using CSS

        • And Then There’s HTML5

        • The Apache Web Server

Tài liệu cùng người dùng

Tài liệu liên quan