一、字符串基础函数
ltrim: 去除连续空白。
trim: 截去字符串首尾的空格。
Chop: 函数从字符串的末端开始删除空白字符或其他预定义字符。(rtrim别名)
<?php
$str = "Hello World!\n\n";
echo $str;
echo chop($str);
?>
输出:
Hello World! Hello World!
htmlspecialchars(string,quotestyle,character-set): 函数把一些预定义的字符转换为 HTML 实体。
预定义的字符是:
& (和号) 成为 &
" (双引号) 成为 "
' (单引号) 成为 '
< (小于) 成为 <
> (大于) 成为 >
例子
<html>
<body>
<?php
$str = "John & 'Adams'";
echo htmlspecialchars($str, ENT_COMPAT);
echo "<br />";
echo htmlspecialchars($str, ENT_QUOTES);
echo "<br />";
echo htmlspecialchars($str, ENT_NOQUOTES);
?>
</body>
</html>浏览器输出:
John & 'Adams'
John & 'Adams'
John & 'Adams'如果在浏览器中查看源代码,会看到这些 HTML:
<html>
<body>
John & 'Adams'<br />
John & & ......
看了些PHP的基础知识,自己在这里总结下:
1,在HTML嵌入PHP脚本有三种办法:
<script language="php">
//嵌入方式一
echo("test");
</script>
<?
//嵌入方式二
echo "<br>test2";
?>
<?php
//嵌入方式三
echo "<br>test3";
?>
还有一种嵌入方式,即使用和Asp相同的标记<%%>,但要修改PHP.ini 相关配置,不推荐使用。
2,PHP注释分单行和多行注释,和java注释方式相同。
<?
//这里是单行注释
echo "test";
/*
这里是多行注释!可以写很多行注释内容
*/
?>
注意不要有嵌套注释,如/*aaaa/*asdfa*/asdfasdfas*/,这样的注释会出现问题。
3,PHP主要的数据类型有5种:
integer,double,string,array,object。
4,函数内调用函数外部变量,需要先用global进行声明,否则无法访问,这是PHP与其他程序语言的一个区别。事例代码:
<?
$a=1;
function test(){
echo $a;
}
test(); //这里将不能输出结果“1”。
function test2(){
global $a;
echo $a;
}
test2(); / ......
所需软件源代码包:
httpd-2.2.4.tar.gz mysql-5.0.27.tar.gz php-5.2.1.tar.bz2
freetype-2.3.2.tar.gz gd-2.0.34.tar.gz jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.bz2 libxml2-2.6.24.tar.bz2 zlib-1.2.2.tar.gz
安装顺序:apache -> mysql -> freetype -> jpegsrc.v6b -> libpng -> libxml -> zlib -> gd -> php ( freetype,jpegsrc.v6b,libxml,zlib,libpng 的安装顺序不限)
约定目录:/usr/local/src 软件源代码包存放位置
/usr/local/software_name 源码包编译安装位置
安装命令:
1 apache
# cd /usr/local/src
# t ar xzvf http-2.2.4.tar.gz
# cd http-2.2.4
# ./configure \
"--prefix=/usr/local/apache2" \
"--enable-module=so" \
"--enable-deflate=shared" \
&nbs ......
所需软件源代码包:
httpd-2.2.4.tar.gz mysql-5.0.27.tar.gz php-5.2.1.tar.bz2
freetype-2.3.2.tar.gz gd-2.0.34.tar.gz jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.bz2 libxml2-2.6.24.tar.bz2 zlib-1.2.2.tar.gz
安装顺序:apache -> mysql -> freetype -> jpegsrc.v6b -> libpng -> libxml -> zlib -> gd -> php ( freetype,jpegsrc.v6b,libxml,zlib,libpng 的安装顺序不限)
约定目录:/usr/local/src 软件源代码包存放位置
/usr/local/software_name 源码包编译安装位置
安装命令:
1 apache
# cd /usr/local/src
# t ar xzvf http-2.2.4.tar.gz
# cd http-2.2.4
# ./configure \
"--prefix=/usr/local/apache2" \
"--enable-module=so" \
"--enable-deflate=shared" \
&nbs ......
所需软件源代码包:
httpd-2.2.4.tar.gz mysql-5.0.27.tar.gz php-5.2.1.tar.bz2
freetype-2.3.2.tar.gz gd-2.0.34.tar.gz jpegsrc.v6b.tar.gz
libpng-1.2.8.tar.bz2 libxml2-2.6.24.tar.bz2 zlib-1.2.2.tar.gz
安装顺序:apache -> mysql -> freetype -> jpegsrc.v6b -> libpng -> libxml -> zlib -> gd -> php ( freetype,jpegsrc.v6b,libxml,zlib,libpng 的安装顺序不限)
约定目录:/usr/local/src 软件源代码包存放位置
/usr/local/software_name 源码包编译安装位置
安装命令:
1 apache
# cd /usr/local/src
# t ar xzvf http-2.2.4.tar.gz
# cd http-2.2.4
# ./configure \
"--prefix=/usr/local/apache2" \
"--enable-module=so" \
"--enable-deflate=shared" \
&nbs ......
1.mysql
在如下页面下载mysql的for linux rpm包
http://www.mysql.com/downloads/down...3.52-1.i386.rpm ;
http://www.mysql.com/downloads/down...3.52-1.i386.rpm ;
存至/home/tmp目录
命令列表:
cd /home/tmp
rpm -ivh MySQL-3.23.52-1.i386.rpm #安装mysql server
rpm -ivh MySQL-client-3.23.52-1.i386.rpm #安装mysql client
/usr/mysql/safe_mysqld & #启动mysql server
mysql #运行mysql 客户端,并开放root用户的远程访问权限。以便调试
use mysql
update user set host = '%' where user = 'root' and host <> 'localhost';
flush privileges;
quit
至此mysql安装完成
2.apache
在如下页面下载apache的for linux 的源码包
http://www.apache.org/dist/httpd/apache_1.3.26.tar.gz ;
存至/home/tmp目录
命令列表:
cd /home/tmp
tar -zxvf apache_1.3.26.tar.gz
mv apache_1.3.26.tar.gz apache
cd apache
./configure --prefix=/usr/local/apache --enable-module=so
m ......
1.mysql
在如下页面下载mysql的for linux rpm包
http://www.mysql.com/downloads/down...3.52-1.i386.rpm ;
http://www.mysql.com/downloads/down...3.52-1.i386.rpm ;
存至/home/tmp目录
命令列表:
cd /home/tmp
rpm -ivh MySQL-3.23.52-1.i386.rpm #安装mysql server
rpm -ivh MySQL-client-3.23.52-1.i386.rpm #安装mysql client
/usr/mysql/safe_mysqld & #启动mysql server
mysql #运行mysql 客户端,并开放root用户的远程访问权限。以便调试
use mysql
update user set host = '%' where user = 'root' and host <> 'localhost';
flush privileges;
quit
至此mysql安装完成
2.apache
在如下页面下载apache的for linux 的源码包
http://www.apache.org/dist/httpd/apache_1.3.26.tar.gz ;
存至/home/tmp目录
命令列表:
cd /home/tmp
tar -zxvf apache_1.3.26.tar.gz
mv apache_1.3.26.tar.gz apache
cd apache
./configure --prefix=/usr/local/apache --enable-module=so
m ......
php教程 调用mssql存储过程实例应用
用mssql_init语句用于初始化存储过程,而后调用mssql_bind语句指定存储过程参数,最后调用mssql_execute执行存储过程。
*/
//连接mssql数据库教程服务器
$link = mssql_connect("127.0.0.1", "sa", "sa") or die("Can't connect sql server");
mssql_select_db("frrc", $link) or die("Select database failure");
//初始化并加载存储过程 Bigdatabase
$stmt = mssql_init("Bigdatabase", $link) or die("initialize stored procedure failure");
mssql_bind($stmt, "@pagesize", $pagesize, SQLINT4);
mssql_bind($stmt, "@start", $start, SQLINT4);
@$ms_result = mssql_execute($stmt, false);
mssql_query("DUMP TRANSACTION tempdb WITH NO_LOG");
do{
while( $ms_rs = mssql_fetch_object($ms_result) )
{
//进行数据处理
}
}
// msssql 存储过程 Bigdatabase如下 ......
php教程 调用mssql存储过程实例应用
用mssql_init语句用于初始化存储过程,而后调用mssql_bind语句指定存储过程参数,最后调用mssql_execute执行存储过程。
*/
//连接mssql数据库教程服务器
$link = mssql_connect("127.0.0.1", "sa", "sa") or die("Can't connect sql server");
mssql_select_db("frrc", $link) or die("Select database failure");
//初始化并加载存储过程 Bigdatabase
$stmt = mssql_init("Bigdatabase", $link) or die("initialize stored procedure failure");
mssql_bind($stmt, "@pagesize", $pagesize, SQLINT4);
mssql_bind($stmt, "@start", $start, SQLINT4);
@$ms_result = mssql_execute($stmt, false);
mssql_query("DUMP TRANSACTION tempdb WITH NO_LOG");
do{
while( $ms_rs = mssql_fetch_object($ms_result) )
{
//进行数据处理
}
}
// msssql 存储过程 Bigdatabase如下 ......
Apache 2 and PHP Installation
The following notes are how I got Apache 2 and PHP 5 (or PHP 4) working together on Linux. These instructions also apply, mostly, for any UNIX-like system, especially other Linux distributions. If you have a recent Linux distribution (say since 2002), you already have Apache 2 and PHP, so you don't need to do this unless you want the latest Apache 2 or PHP release or need to customize the Apache or PHP software. Don't forget to remove (or at least disable) the Apache rpm package if you install your own custom Apache.
Apache 2 Version Tip: Beginning with Apache 2.0.42 the API will be kept stable (yeah!). That means you will NOT have to recompile modules (and possibly upgrade/fix source) every time you install a new Apache release. This assumes you stay in the same Apache release series. For example, upgrading from 2.2.0 to 2.2.2 should work. This will not apply to upgrading to the next series (e.g., "development" 2.3.x or "stable" 2.4.x). ......