PHP Session用法
<?php
header(“Content-Type: text/html;charset=utf-8”);
// session_start
session_start();
$_SESSION[‘user_session’] = “0101”;
echo $_SESSION[‘user_session’];
?>
<?php
header(“Content-Type: text/html;charset=utf-8”);
// session_start
session_start();
$_SESSION[‘user_session’] = “0101”;
echo $_SESSION[‘user_session’];
?>
<?php
// 写入
// time()+3600指的是该cookie的生存周期,秒为位,1个小时(60秒*60分钟)
setcookie(“usercode”, “9001”, time()+3600);
// 读取
echo $_COOKIE[“usercode”];
echo “<br/>”;
if (isset($_COOKIE[“usercode”]))
echo “Welcome ” . $_COOKIE[“usercode”] .
<?php
// 定义变量
$name = ‘jzh’;
echo $name;
echo ‘<br>’;
// 字符串拼接
$a = ‘a’;
$b = ‘b’;
$c = $a . $b;
echo $c;
echo ‘<br>’;
// 数字相加
$i = 1;
$j = 2;
$k = $i + $j;
echo $k;
echo ‘<br>’;
// 定义常量
define
<?php
//substr() 函数返回字符串的一部分
//substr(string,start,length)
//echo substr(“jiangzhihao”, 6);
echo substr(“jiangzhihao”, 0, 5);
//strlen() 函数返回字符串的长度
echo strlen(“jiangzhihao”);
//trim() 函数移除字符串两侧的空白字符
echo trim(“
jiangzhihao
“);
<?php
$flag = “1”;
switch ($flag) {
case “0”:
echo “userAdd”;
break;
case “1”:
echo “userUpdate”;
break;
case “2”:
echo “userDel”;
break;
default:
echo “userGet”;
}
?>
Apache2+PHP5+MySQL5的相关软件版本如下:
apache_2.2.4-win32-x86-no_ssl.msi
php-5.2.3-Win32.zip
mysql-5.0.27-win32.zip
phpMyAdmin-2.10.3-rc1-all-languages.zip
1、Apache
httpd.conf文件修改
LoadModule php5_module “D:\app\php5\php5apache2_2.dll”
AddType application/x-
using System;
using System.Collections.Generic;
using System.Text;
///Mediator(中介者)模式 用一个中介对象来封装一系列的对象之间的交互,中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互。
///add by jzh 2007-04-30
namespace DesignPattern
{
/// <summary>
/// 抽象中
查找user_code出现重复的情况
select user_code, count(user_code) as num from app_users group by user_code having count(user_code) > 1
using System;
using System.Collections.Generic;
using System.Text;
///Memento(备忘录)模式 在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态,这样以后就可将该对象恢复到原先保存的状态。
///add by jzh 2007-04-29
namespace DesignPattern
{
/// <summary>
/// Originator(
— % 替代 0 个或多个字符
select * from app_users where user_name like ‘i%’
— _ 替代一个字符
select * from app_users where user_name like ‘_dodo.xin’
1、case。
select DeptName,
isnull(sum(1),0) as cAll,
isnull(sum(case when isnull(A01072,’已审核’) = ‘已审核’ then 1 end),0) as cYes,
isnull(sum(case when isnull(A01072,’未审核’) = ‘未审核’ then 1 end),0) as cNo
from view_UserStandInfo group by DeptName
using System;
using System.Collections.Generic;
using System.Text;
///Template Method(模板方法)模式定义一个操作中的算法的骨架,将具体的处理细节交给子类具体实现。
///add by jzh 2007-04-26
namespace DesignPattern
{
/// <summary>
/// 抽象模版(AbstractClass)角色
/// 定义了
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
///Flyweight(享元)模式采用共享来避免大量拥有相同内容对象的开销。
///add by jzh 2007-04-24
namespace DesignPattern
{
/// <summary>
/// 享元工厂(FlyweightFactory
using System;
using System.Collections.Generic;
using System.Text;
///Decorator(装饰器)模式 通过对已经存在的某些类进行装饰,以此来扩展一些功能。
///add by jzh 2007-04-24
namespace DesignPattern
{
/// <summary>
/// Component(抽象构件)角色:给出一个抽象接口,以规范准备接收附加责任的对象。
using System;
using System.Collections.Generic;
using System.Text;
///Chain of Responsibility(职责链,以下简称CoR)模式通过将多个对象串接成一条链(Chain),并沿着这条链传递上层应用传来的请求,
///直到有一个对象处理它为止,使得多个对象都有机会处理上层应用传来的请求,从而避免请求的发送者和接收者之间的耦合关系。
///add by jzh 2007-04-23
n
using System;
using System.Collections.Generic;
using System.Text;
///Bridge(桥接)模式将抽象部分与它的实现部分进行分离,使它们都可以独立地变化。
///add by jzh 2007-04-18
namespace DesignPattern
{
class Abstraction
{
protected Implementation impDefault;
public
using System;
using System.Collections.Generic;
using System.Text;
///Singleton(单件)模式用于保证一个类仅有一个实例,并提供一个访问该实例的全局访问点。
///add by jzh 2007-04-15
namespace DesignPattern
{
class Singleton
{
private static Singleton _instance;
publi
using System;
using System.Collections.Generic;
using System.Text;
///Visitor(访问者)模式 用于表示一个作用于某对象结构中的各元素的操作,在不改变各元素的类的前提下定义作用于这些元素的新操作。
///add by jzh 2007-04-15
namespace DesignPattern
{
/// <summary>
/// Visitor(访问者):为该对象结构中
using System;
using System.Collections.Generic;
using System.Text;
///Strategy(策略)模式又称Policy模式,用于定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换。
///add by jzh 2007-04-29
namespace DesignPattern
{
/// <summary>
/// strategy
定义所有支持的算法的公共接口.