Home PHP and MySQL Introduction

PHP and MySQL - Introduction


PHP Introducing PHP PHP Basics Creating PHP scripts Outputting data with echo and print String literals Variables Types Constants Expressions, Operators, and Variable Assignment Expressions Operator precedence Type Conversion Automatic type conversion Examining Variable Type and Content Testing, setting, and unsetting variables Conditions and Branches if...else Statement switch Statement Conditional Expressions Loops while do...while for foreach Changing Loop Behavior A Working Example Comments on Example 2.3 ArraysCreating Arrays Associative arrays Heterogeneous arrays Multidimensional arrays Using foreach Loops with Arrays Using Array Pointers Basic Array Functions Counting elements in arrays Finding the maximum and minimum values in an array Finding values in arrays with in_array() and array_search() Reordering elements in arrays with array_reverse() Sorting Arrays Sorting with sort() and rsort() Sorting associative arrays Sorting on keys Sorting with user-defined element comparison Strings String Literals Variable substitution Length of a string Printing and Formatting Strings Creating formatted output with sprintf() and printf() Padding strings Changing case Trimming whitespace Comparing Strings Finding and Extracting Substrings Extracting a substring from a string Finding the position of a substring Extracting a found portion of a string Extracting multiple values from a string Replacing Characters and Substrings Replacing substrings Translating characters and substrings Regular Expressions Regular Expression Syntax Characters and wildcards Character lists Anchors Optional and repeating characters Groups Alternative patterns Escaping special characters Metacharacters Regular Expression Functions Finding and extracting values Replacing substrings Splitting a string into an array Date and Time Functions Generating a Timestamp Current time Creating timestamps with mktime() and gmmktime() String to timestamp Subsecond times Formatting a Date Validating a Date Integer and Float Functions Absolute Value Ceiling and Floor Rounding Number Systems Basic Trigonometry Functions Powers and Logs Random Number Generation User-Defined Functions Argument Types and Return Types Variable Scope Global variables How Variables Are Passed to Functions Passing arguments by reference Assigning by reference Default argument values Reusing Functions with Include and Require Files Objects Classes and Objects Inheritance Common Mistakes A Page That Produces Partial or No Output Variable Problems Variable naming Missing output Complaints About Headers Other Common Problems

The topics covered in this tutorial include:

  • PHP basics, including script structure, variables, supported types, constants, expressions, and type conversions
  • Condition and branch statements supported by PHP, including if, if...else, and the switch statements
  • Looping statements
  • Arrays and array library functions
  • Strings and string library functions
  • Regular expressions
  • Date and time functions
  • Integer and float functions
  • How to write functions, reuse components, and determine the scope and type of variables
  • An introduction to PHP object-oriented programming support
  • Common mistakes made by programmers new to PHP, and how to solve them

[Next]