易截截图软件、单文件、免安装、纯绿色、仅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
/* @author: zhuyubing@gmail.com */
class Template{
        var $code;
        function Template($template){
            $this->code = implode('', @file($tem ......

PHP 调用 C# dll

弄了半天, PHP 终于能调用我的C# dll 了.
该死的,我对C# COM注册一向不了解, PHP 文档上只给PHP那部分内容,没告诉我怎么弄dll
我还傻兮兮的用 Regsvr32 注册那个c# dll.
背景:
Windows xp sp3 ; apache 2.2.14 ; php 5.2.12 ;
VS2010 beta ;
语言:
PHP5 , C#
C#部分:
创建一个 C# Class Library . (dll) ......

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号