janneyabc 发表于 2015-8-28 10:34:20

PHP 学习笔记

  1. What is PHP?
  PHP stands for:Hypertext Preprocessor
  It is a server-side scriting language
  Excuted on the server
  Support many DB:MySql, Informix,Oracle,Sybase,Solid etc.
  OSS, Free to download and use
  PHP file returned to the browser as plain HTML
  PHP file have file extension of ".php","php3" or ".phtml"
  PHP combined with MySQL are cross-platform
  use // to make a single-line comment or /* and */to make a large
  All variables in PHP start with a $ sign symbol
  PHP is a Loosely Typed Language
  The concatenation operator (.)is used to put two string values together.
  strlen() function is used to find the length of a string
  The strpos() function is used to search for a string or character within a string
  Numeric Arrays:

$names = array("Peter","Quagmire","Joe"); =

$names = "Peter";
$names = "Quagmire";
$names = "Joe";
  Associative Arrays:
  $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);

$ages['Peter'] = "32";
$ages['Quagmire'] = "30";
$ages['Joe'] = "34";
  Multidimensional Arrays:

$families = array
(
"Griffin"=>array
(
"Peter",
"Lois",
"Megan"
),
"Quagmire"=>array
(
"Glenn"
),
"Brown"=>array
(
"Cleveland",
"Loretta",
"Junior"
)
);

Array
(
=> Array
(
=> Peter
=> Lois
=> Megan
)
=> Array
(
=> Glenn
)
=> Array
(
=> Cleveland
=> Loretta
=> Junior
)
)

Post: Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send
<form action="welcome.php" method="post"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /><input type="submit" /> </form>
URL:
http://www.w3schools.com/welcome.php

welcome.php:
Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old.
  Get:Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and it has limits on the amount of information to send (max. 100 characters).

<form action="welcome.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
URL:
http://www.w3schools.com/welcome.php?name=Peter&age=37

welcome.php:

Welcome <?php echo $_GET["name"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!
Data function:date("Y/m/d",mktime(hour,minute,second,month,day,year,is_dst)
include a file:<?php include("header.php");
open a life;--
页: [1]
查看完整版本: PHP 学习笔记