文档介绍:PHP Tutorial
I-Ming Lee
6/30/2017
1
PHP Hypertext Preprocessor
PHP is a server-side interpreted programming language used by web developers to create dynamic website which can interact and change based on users’ actions. PHP is used in over million websites. It exists as one of the most widely used dynamic web scripting languages.
6/30/2017
2
PHP Functions
PHP runs on different platforms (Windows, Linux, Unix, MacOS).
PHP is a Server-Side Scripting language.
PHP scripts are executed on the server.
PHP code is embedded in HTML code.
PHP has syntax very similar to other high-level languages (C, Python, Perl, ASP).
PHP is an Open-Source software and is free to download and use.
PHP is designed to perform very well with other open source web solutions (MySQL, Apache).
6/30/2017
3
PHP Installation
Download PHP:
Download MySQL Database: nloads/
Download Apache Server: http://httpd./
6/30/2017
4
PHP Syntax
CODE:
<?php
echo “hello world!”;
//prints the string “hello world!”
?>
All PHP code starts and ends with <?php or <? and ?> ments all begin with //
echo is for output and the string is contained in double quotes.
6/30/2017
5
PHP Variables
Variables are used for storing a values, like text strings, numbers or arrays.
When a variable is declared, it can be used over and over again in users’ script.
All variable in PHP start with a $ sign symbol.
6/30/2017
6
PHP Variable Example
Creating a variable containing a string, and a variable containing a number:
<?php
$txt = “Hello World!”;
$x = 16;
?>
6/30/2017
7
Naming Rules for Variables
A variable name must start with a letter or an underscore “_”
A variable name can only contain alpha- numeric characters and underscore (a-z, A-Z, 0-9, _).
A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an _ ($my_txt), or with capitalization ($myTxt).
6/30/2017
8
PHP String Variables
The PHP script assigns the