易截截图软件、单文件、免安装、纯绿色、仅160KB

php单引号和双引号的区别

本文转自http://xfs39.javaeye.com/blog/411508 感谢作者分享
php单引号和双引号的区别



    今天,有一新学PHP的网友问了茶农一个问题:“单引号和双引号的区别和用法?”,现将答案总结了下,写成这篇小短文。
" "双引号里面的字段会经过编译器解释,然后再当作HTML代码输出。
' '单引号里面的不进行解释,直接输出。
例如:
$abc='my name is tome';
echo $abc //结果是:my name is tom
echo '$abc' //结果是:$abc
echo "$abc" //结果是:my name is tom
特别在使用MYSQL语句的时候,双引号和单引号的用法让新手不知所措,在这里,举个例子,来进行说明。
假设查询条件中使用的是常量,例如:
select    *    from    abc_table where user_name='abc';
SQL语句可以写成:
SQLstr = "select    *    from abc_table where user _name= 'abc'" ;
假设查询条件中使用的是变量,例如:
$user_name = $_REQUEST['user_name']; //字符串变量

$user=array ("name"=>
$_REQUEST['user_name‘,"age"=>$_REQUEST['age'];//数组变量
SQL语句就可以写成:
SQLstr = "select    *    from abc_table where user_name = ' " .
$user_name . " ' ";
SQLstr = "select * from abc_table where user_name = ' " .
$user["name"] . " ' ";
对比一下:
SQLstr="select * from abc_table where user_name = ' abc ' " ;
SQLstr="select * from abc_table where user_name =' " . $user _name .
" ' ";
SQLstr="select * from abc_table where user_name =' " . $user["name"]
. " ' ";
SQLstr可以分解为以下3个部分:
1:"select * from table where user_name = ' " //固定SQL语句
2:$user //变量
3:" ' "
1,2,3部分字符串之间用"." 来连接


相关文档:

PHP多维数组

/***************************by
garcon1986********************************/
一个三维数组的显示,保存以备以后使用。
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$conn = mysql_connect("localhost","charle ......

一天学会php(上)

我这里说的一天学会是有前提的,首先你需要有编程的经验(不管何种语言),还有这里只是说学会,不是精通。由于我学习php也是为了搞个个人网站玩玩的,不是为了吃饭的,呵呵。
首先,讲语法PHP的语法。
嵌入方法:
类似ASP的,PHP中也可以。一般使用<?php      ?>这样形式
逻辑运算:
......

php 模板写法


<?php
/* @author: zhuyubing@gmail.com */
class Template{
        var $code;
        function Template($template){
            $this->code = implode('', @file($tem ......

在 Windows 下安装 PHP 开发环境(基于 Appserv)

1.Appserv 是什么?
  Appserv 是PHP网页架站工具组合包,可以将网络上免费的架站资源重新包装成单一的安装程序。它提供了简易、快速的PHP运行环境的搭建机制,读者只需按照普通应用软件的安装方式就可以完成Apache+MySQL+PHP+phpMyAdmin的安装与配置工作。
2.Appserv 下载地址
   http://www. ......

how to install apache, PHP and MySQL on Linux

how to install apache, PHP and MySQL on Linux
This tutorial explains the installation of Apache web server, bundled with PHP and MySQL server on a Linux machine. The tutorial is primarily for SuSE 9.2, 9.3, 10.0 & 10.1 operating systems, but most of the steps ought to be valid for all Linux-lik ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号