<?php
$start=$_GET['s'];
$end=$_GET['e'];
$requests = array();
for ($index = $start; $index < $end; $index++) {
$url="http://www.essort.com/amfphp/services/curl/loadTest.php?uid=$index";
$requests[]=$url;
}
$main = curl_multi_init();
$results = array();
$errors = array();
$info = array();
$count = count($requests);
for($i = 0; $i < $count; $i++) {
$handles[$i] = curl_init($requests[$i]);
var_dump($requests[$i]);
curl_setopt($handles[$i], CURLOPT_URL, $requests[$i]);
curl_setopt($handles[$i], CURLOPT_RETURNTRANSFER, 1);
curl_multi_add_handle($main, $handles[$i]);
}
$running = 0;
do {
curl_multi_exec($main, $running);
} while($running > 0);
for($i = 0; $i < $count; $i++)
{
$results[] = curl_multi_getcontent($handles[$i]);
$errors[] = curl_error($handles[$i]);
$info[] = curl_getinfo($handles[$i]);
curl_multi_remove_handle($main, $handles[$i]);
}
curl_multi_close($main);
var_dump($results);
var_dump($e ......
注:这是从PHPCMS开发文档里看到编码规范,虽名为PHPCMS的开发规范,但我觉得所有的PHP编程都该如此。写了那么多PHP,很多编码对照这规范都感觉欠缺很多,今后一定要对照纠正。
Phpcms 编码规范
1. 引言…. 2
2. 适用范围…. 2
3. 标准化的重要性和好处…. 3
4. PHP编码规范与原则…. 3
4.1. 代码标记… 3
4.2. 注释… 3
4.3. 书写规则… 4
4.3.1. 缩进… 4
4.3.2. 大括号{}、if和switch. 4
4.3.3. 运算符、小括号、空格、关键词和函数… 5
4.3.4. 函数定义… 6
4.3.5. 引号… 6
4.3.6. 多语言问题… 7
4.4. 命名原则… 8
4.4.1. 变量、对象、函数名… 8
4.4.2. 常量… 8
4.5. 变量的初始化与逻辑检查… 8
4.6. 安全性… 9
4.7. 兼容性… 9
4.8. 代码重用… 10
4.9. 其他细节问题… 10
4.9.1. 包含调用… 10
4.9.2. 错误报告级别… 11
5. 数据库设计…. 11
5.1. 字段… 11
5.1.1. 表和字段命名… 11
5.1.2. 字段结构… 11
5.2. SQL语句… 12
5.3. 性能与效率… ......
1、到微软官方去下载新的驱动,下载地址如下:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9
官方文档有描述:
Refer to the documentation that is installed with the driver for a description of the new features in this release. The SQL Server Driver for PHP download is available to all SQL Server users at no additional charge. The SQL Server Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2008.
根据官方文档的描述,微软提供的Driver是同时提供给SQL Server 2005和SQL Server 2008两个版本使用的。
下载驱动(上边有链接地址)下载过后的驱动包里面的内容如下图:
2、需要修改C:\WINDOWS\php.ini中的配置:
查找;extension_dir 修改为extension_dir="E:\Pr ......
1、到微软官方去下载新的驱动,下载地址如下:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9
官方文档有描述:
Refer to the documentation that is installed with the driver for a description of the new features in this release. The SQL Server Driver for PHP download is available to all SQL Server users at no additional charge. The SQL Server Driver for PHP is a PHP 5 extension that allows for the reading and writing of SQL Server data from within PHP scripts. The extension provides a procedural interface for accessing data in all editions of SQL Server 2005 and SQL Server 2008.
根据官方文档的描述,微软提供的Driver是同时提供给SQL Server 2005和SQL Server 2008两个版本使用的。
下载驱动(上边有链接地址)下载过后的驱动包里面的内容如下图:
2、需要修改C:\WINDOWS\php.ini中的配置:
查找;extension_dir 修改为extension_dir="E:\Pr ......
使用过SQL Server的人应该都清楚,SQL Server常用的有两种认证方式,一种是本地系统账户认证(Windows Authentication ),一种是使用用户名和密码(SQL Server Authentication ),第二种认证方式必须启用SQL Server的混合模式。
1.Windows Authentication连接部分代码段:
<?php
$serverName = "(local)";
$connectionInfo = array("Database"=>"TestingInfo","ConnectionPooling"=>false);
$conn = sqlsrv_connect( $serverName,$connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
?>
2.SQL Server Authentication连接部分代码段:
<?php
$serverName = "(local)";
$uid = "sa";
$pwd = "******";
$connectionInfo = array("UID"=>$uid,"PWD"=>$pwd,"Database"=>"TestingInfo");
$conn = sqlsrv_connect( $serverName,$connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
?>
参考官方提供的英文原文档,针对参数$conne ......
使用过SQL Server的人应该都清楚,SQL Server常用的有两种认证方式,一种是本地系统账户认证(Windows Authentication ),一种是使用用户名和密码(SQL Server Authentication ),第二种认证方式必须启用SQL Server的混合模式。
1.Windows Authentication连接部分代码段:
<?php
$serverName = "(local)";
$connectionInfo = array("Database"=>"TestingInfo","ConnectionPooling"=>false);
$conn = sqlsrv_connect( $serverName,$connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
?>
2.SQL Server Authentication连接部分代码段:
<?php
$serverName = "(local)";
$uid = "sa";
$pwd = "******";
$connectionInfo = array("UID"=>$uid,"PWD"=>$pwd,"Database"=>"TestingInfo");
$conn = sqlsrv_connect( $serverName,$connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
?>
参考官方提供的英文原文档,针对参数$conne ......
apache安装,mysql安装,php5直接解压,均放在D:\www下。
目录结构为:
D:\www\apache2
D:\www\mysql
D:\www\php5
将php5\php.ini-dist复制为php.ini,把需要用到的组件将前面的;去掉。
如
extension=php_mysql.dll
extension=php_gd2.dll
在apache2的conf/httpd.conf文件中加
LoadFile D:/www/php5/php5ts.dll
LoadFile D:/www/php5/libmysql.dll
LoadModule php5_module D:/www/php5/php5apache2_2.dll
AddType application/x-httpd-php .php
PHPIniDir "D:/www/php5"
完成了! 无需复制任何文件到C:\windows下,呵呵!
即使系统重装,配置也都会在哦:)
如果服务器重装,就只需要重装下apache2和mysql到原目录,当然原目录也要先备份一下以确保安全。
以下是我对apache2的一些设置,记录一下。
<IfModule mpm_winnt.c>
ThreadsPerChild 150
MaxRequestsPerChild 10000
Win32DisableAcceptEx
</IfModule>
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
我把虚拟主机等配置内容都放在extra/httpd-vhosts.conf下的,所以这样设置。
apache2的详细配置请参见文档:http://www.itlearner.com/code/apache2.2/
php.ini ......
apache安装,mysql安装,php5直接解压,均放在D:\www下。
目录结构为:
D:\www\apache2
D:\www\mysql
D:\www\php5
将php5\php.ini-dist复制为php.ini,把需要用到的组件将前面的;去掉。
如
extension=php_mysql.dll
extension=php_gd2.dll
在apache2的conf/httpd.conf文件中加
LoadFile D:/www/php5/php5ts.dll
LoadFile D:/www/php5/libmysql.dll
LoadModule php5_module D:/www/php5/php5apache2_2.dll
AddType application/x-httpd-php .php
PHPIniDir "D:/www/php5"
完成了! 无需复制任何文件到C:\windows下,呵呵!
即使系统重装,配置也都会在哦:)
如果服务器重装,就只需要重装下apache2和mysql到原目录,当然原目录也要先备份一下以确保安全。
以下是我对apache2的一些设置,记录一下。
<IfModule mpm_winnt.c>
ThreadsPerChild 150
MaxRequestsPerChild 10000
Win32DisableAcceptEx
</IfModule>
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
我把虚拟主机等配置内容都放在extra/httpd-vhosts.conf下的,所以这样设置。
apache2的详细配置请参见文档:http://www.itlearner.com/code/apache2.2/
php.ini ......
1.apache的安装
apache本来是想用编译安装的,但是其devel需要依赖一些其他的包,安装起来太麻烦,所以决定使用本地yum源安装;在rhel5u3上,直接 yum install httpd
yum install httpd-devel
这样会有httpd-devel的一些依赖包一并安装了;
rpm安装的httpd有如下几个重要的目录:
1)/etc/httpd
httpd的配置主目录:
/etc/httpd/conf/httpd.conf是其主配置文件;
/etc/httpd/logs是一个软连接,连接目录为:/var/log/httpd这个目录有apache的访问日志,异常错误日志等;
/etc/httpd/modules也是一个软连接,连接目录为:/usr/lib/httpd/modules,这个是一些apache module存放目录;
/etc/httpd/conf.d/这个目录下的所有.conf文件都会作为apache的扩展配置文件加载;
2)/usr/share/doc/httpd-2.2.3/
这个目录是httpd的一些帮助文档所在地
3)/etc/rc.d/init.d/httpd
可以使用service httpd start/stop/status/restart等管理httpd服务;
4)/var/www/html
这个是DocumentRoot目录;
2.mysql的安装
如果要是安装php mysql一般需要安装如下3个rpm包:
MySQL-server-community-5.1.45-1.rhel5.i386.rpm,MySQL-client-community-5.1.45-1 ......
1.apache的安装
apache本来是想用编译安装的,但是其devel需要依赖一些其他的包,安装起来太麻烦,所以决定使用本地yum源安装;在rhel5u3上,直接 yum install httpd
yum install httpd-devel
这样会有httpd-devel的一些依赖包一并安装了;
rpm安装的httpd有如下几个重要的目录:
1)/etc/httpd
httpd的配置主目录:
/etc/httpd/conf/httpd.conf是其主配置文件;
/etc/httpd/logs是一个软连接,连接目录为:/var/log/httpd这个目录有apache的访问日志,异常错误日志等;
/etc/httpd/modules也是一个软连接,连接目录为:/usr/lib/httpd/modules,这个是一些apache module存放目录;
/etc/httpd/conf.d/这个目录下的所有.conf文件都会作为apache的扩展配置文件加载;
2)/usr/share/doc/httpd-2.2.3/
这个目录是httpd的一些帮助文档所在地
3)/etc/rc.d/init.d/httpd
可以使用service httpd start/stop/status/restart等管理httpd服务;
4)/var/www/html
这个是DocumentRoot目录;
2.mysql的安装
如果要是安装php mysql一般需要安装如下3个rpm包:
MySQL-server-community-5.1.45-1.rhel5.i386.rpm,MySQL-client-community-5.1.45-1 ......