PHP的最简单用法

<?php
include("library.php");
include_once("library.php");
require_once("library.php");

echo "Hello world";
$username = "Fred Smith";
echo $username;
echo str_repeat("Hip ", 2);   // Repeat string
echo strtoupper("hooray!");   // String to upper case
$n3 = ucfirst(strtolower($n3));    // 首字母改成大写
echo substr($number, 4, 1);
    $n1 = ucfirst(strtolower($n1));

echo "<br />";
echo "a: [" . (20 > 9) . "]<br />";
$myarray   = array("One", "Two", "Three");
$number = 12345 * 67890;
?>


<?php
$author = "Alfred E Newman";

echo <<<_END  // 一直到底
This is a Headline

This is the first line.
This is the second.
- Written by $author.
_END;
?>

<?php
function longdate($timestamp)
{
    return date("l F jS Y", $timestamp);
    $temp = date("l F jS Y", $timestamp);
    return "The date is $temp";    
    
}
echo longdate(time());
function longdate($timestamp)
{
    $temp = "The date is ";
    return $temp.date("l F jS Y", $timestamp);
}
?>

<?php
$temp = "The date is ";
echo longdate($temp, time());

function longdate($text, $timestamp)
{
    return $text . date("l F jS Y", $timestamp);
}
?>

<?php
if     ($page == "Home")  echo "You selected Home";
elseif ($page == "About") echo "You selected About";
elseif ($page == "News")  echo "You selected News";
elseif ($page == "Login") echo "You selected Login";
elseif ($page == "Links") echo "You selected Links";
switch ($page)
{
    case "Home":  echo "You selected Home";
        break;
    case "About": echo "You selected About";
        break;
    case "News":  echo "You selected News";
        break;
    case "Login": echo "You selected Login";
        break;
    case "Links": echo "You selected Links";
        break;
}
?>

摘自《[PHP.MySQL.JavaScript学习手册].源代码.zip》,第三第四章。没学到什么东西。

posted @ 2013-02-09 00:15  findumars  Views(482)  Comments(0Edit  收藏  举报