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

PHP字符串中的大括号

<?php
class Model_Data_FocusData{
....
public function getData(){...}
}
class Model_Data_IndexData{
....
public function getData(){...}
}
?> 
 有这么几个类,希望能够自动的根据参数来调用不同的类处理数据。
看调用模块:
<?php

function getData($act){
$class = "Model_Data_{$act}Data";
$model = new $class();
return $model->getData();
}

?> 
这个块看起来没有一点问题,在WAMP下运行也没有问题。
但是移植到LAMP后,发现执行到这一段代码的时候中断了。
问题在哪里呢?
$class = "Model_Data_{$act}Data";
$model = new $class();
看这里,"Model_Data_{$act}Data"; 换成 "Model_Data_".$act."Data";后,这段代码又通过了。
由此得出结论:
 php字符串中加入大括号引用变量时,并没有立即处理该变量,而是最终使用的时候处理,比如:echo的时候,echo这个命令具有解析字串中变量功能,而 new 关键词显然不具备。


相关文档:

判断php变量是否定义,是否为空

isset() 【1】
Returns TRUE if var
exists and has value other
than NULL, FALSE otherwise.
输入可以是多个变量,只有所有的变量为真的时候,返回真
empty()【2】
Returns FALSE if var
has a non-empty
and non-zero value.

The following things are considered to be empty:

"" (an em ......

PHP插入数据库代码,编辑,删除

插入代码
 <?
$action=$_GET['action'];
switch($action){
//添加记录
case"add";
$mail = trim(htmlspecialchars($_POST["mail"]));
$username = trim(htmlspecialchars($_POST["username"]));
$tel = trim(htmlspecialchars($_POST["tel"]));
$fax = trim(htmlspecialchars($_POST["fax"]));
$c ......

PHP用邮件取回忘记密码功能?

wangjimima.php
<form id="form1" name="form1" method="post" action="mailto.php" onSubmit="return CheckForm()">
<input name="username" type="text" class="in" id="username" size="30" onmouseover="fEvent('mouseover',this)" onfocus="fEvent('focus',this)" onblur="fEvent('blur',this)" onmouseout ......

在CENT OS上编译安装APACHE+PHP+MYSQL

 源码目录:/usr/local/src/
 应用目录:/usr/local/app/
一、MYSQL安装。
 1.下载MSYQL源码:
http://www.mysql.com/downloads/mysql/
最近版本是 mysql-5.1.47.tar.gz
2.上传到服务器目录/usr/local/src/
cd /usr/local/src/
tar zxvf mysql-5.1.47.tar.gz
cd mysql-5.1.47
./configure --prefi ......

fedora下php环境配置

编译安装
apache
下载apache安装
=============================
我把他安装在/usr/local/apache目录下
tar -zxvf apache文件
进入解压后的目录,配置./configure --prefix=/usr/local/apache -enable-mods-shared=all -enable-so -enable-rewrite
make
make install
然后启动/usr/local/apache/bin/apachectl sta ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号