易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : php

2010年最新PHP类的精缩归纳

一:结构和调用(实例化):
class className{} ,调用:$obj = new className();当类有构造函数时,还应传入参数。如$obj = new className($v,$v2...);
二:构造函数和析构函数:
1、构造函数用于初始化:使用__construct(),可带参数。
2、但析构函数不能带参数(用于在销去一个类之前执行一些操作或功能)。析构函数用__destruct()做名称。在脚本执行结束时,PHP会销掉内存中的对象,因此可不用析造函数,但有些比如COOKIE等,就应当要用此函数销掉。
知识点:在PHP4中也提供了构造函数,但使用的是与类同名的类方法,在PHP5仍能兼容这种做法,当一个类中没有包含__construct时,会查找与类同名的方法,如果找到,就认为是构造函数,如下:
class test
{ var $b;
function test() {   $this->b=5; }
function addab($c) {   return $this->b+$c; }
}
$a = new test();   echo $a->addab(4); // 返回 9
3、PHP不会自动调用父类的构造函数(不支持构造函数重载),必须使用parent关键字显式地调用。
class employee{
      function __construct()....
}
class Manager extents Employee{
&nb ......

php基本知识

1.php数组基础:
<?php
$ary2 = "zqhung_hongzequan_zqhong";
$arr3 =explode("_",$ary2);//拆分字符串
echo $arr3[1];//打印出来的结果是hongzequan
$ary1 = array("aa","bb");
$ary1[0]="zqhung";//修改数组中的值
echo $ary1[0],"<br>";//打印出来的结果是zqhung
$ary3 = array("id"=>55);
$aa = is_array($ary1);//判断变量是否为数组
echo $aa,"<br>";
echo count($ary1),"<br>";//判断数组中元素的个数
foreach($arr3 as $key=>$value)//遍历数组中的元素
{
echo $value,"<br>";
}
?>
 2.连接mysql
<?php
$conn = @ mysql_connect("localhost", "root", "") or die("连接失败");//连接mysql
mysql_select_db("quanquanfly", $conn) or die("连接失败");//连接quanquanfly数据库
$sql = "insert into aa (name,age) value ('1','2')";
mysql_query($sql, $conn);//执行插入操作
/**
* 执行查询并显示操作
*/
$sql1 = "select * from aa";
$query = mysql_query($sql1,$conn);
$select = mysql_fetch_array($query);
while ($select = mysql_fetch_array($query)) {
echo ......

nginx php mysql

安装 Nginx
* 一条命令搞定:
USE=fastcgi emerge nginx
* 新建用户和组:
groupadd www
useradd www -g www
Nginx 安装好后默认会添加 nginx 组和 nginx 用户,不过我本身还是习惯新建个 www 组和 www 用户来做 HTTP 服务用户。若今后 HTTP 服务器更换为 apache 或是 lighttpd 时,用户名和用户组可以不变。
安装 MySQL
在装 PHP 前必须先装 MySQL,因为 PHP 里的 MySQL 操作函数需要 MySQL 头文件和库的支持。
mysql_install_db --basedir=/usr --datadir=/work/db/3306/data --user=mysql
mkdir -p /work/db/3306/data
mysql_install_db
* 修改配置文件:
vim /etc/mysql/my.cnf
将 datadir 修改为:
datadir = /work/db/3306/data
* 启动 MySQL:
/etc/init.d/mysql start
* 修改 root 密码:
mysqladmin -uroot password hily
* 测试数据库:
mysql -uroot -p
显示:
gentoo setup # mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.84-log Gentoo Linux mysql-5.0.84-r1
Type 'help;' or '\h' for help. Type '\c' to clear the curr ......

用PHP实现一个双向队列

<?php
class DoubleQueue
{
public $queue = array();
/**(尾部)入队 **/
public function push($value)
{
return array_push($this->queue,$value);
}
/**(尾部)出队**/
public function pop()
{
return array_pop($this->queue);
}
/**(头部)入队**/
public function enq($value)
{
return array_unshift($this->queue,$value);
}
/**(头部)出队**/
public function deq()
{
return array_shift($this->queue);
}
/**清空队列**/
public function makeEmpty()
{
return unset($this->queue);
}
}
class DoubleDueue
{
public $queue = array();

public function push($value)
{
return $this->queue[] = $value;
}
public function pop()
{
$count = $this->count();
if($count >= 1)
{
$value = $this->queue[$count-1] ......

YAHOO PHP面试题

知道差距了,努力吧!
1. Which of the following will not add john to the users array?
1. $users[] = 'john';
2. array_add($users,'john');
3. array_push($users,'john');
4. $users ||= 'john';
2. What's the difference between sort(), asort() and ksort? Under what circumstances would you use each of these?
3. What would the following code print to the browser? Why?
$num = 10;
function multiply(){
$num = $num * 10;
}
multiply();
echo $num;
4. What is the difference between a reference and a regular variable? How do you pass by reference & why would you want to?
5. What functions can you use to add library code to the currently running script?
6. What is the difference between foo() & @foo()?
7. How do you debug a PHP application?
8. What does === do? What's an example of something that will give true for '==', but not '==='?
9. How would you declare a class named “myclass” with no methods or properties?
10. How wo ......

php检测ajax方式的调用请求

比如要给用户报告一个错误,用下面的方法:
使用set_error_handler设置自己的错误处理函数,在报错的地方使用trigger_error,在自定义的错误处理函数中给用户显示一个出错信息页面。

是如果调用trigger_error的这个页面是被一次ajax请求触发的,那么ajax返回后将得到一大堆用于显示错误的html代码。而一般
ajax调用都会约定自己的错误信息格式,所以后台php代码要么使用两种不同的报告错误的方式:一种给ajax调用请求使用,一种给普通的页面刷新使
用,要么使用统一的错误报告格式,在报告的时候判断一下这是一个ajax调用请求还是一个普通的页面刷新请求。
在php代码中检测是否ajax调用请求的方法是:
    if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
            strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                 // this is an ajax request
    }
这个方法来自于google搜索,据说只适用于jQuery发出的ajax请求。 ......

php检测ajax方式的调用请求

比如要给用户报告一个错误,用下面的方法:
使用set_error_handler设置自己的错误处理函数,在报错的地方使用trigger_error,在自定义的错误处理函数中给用户显示一个出错信息页面。

是如果调用trigger_error的这个页面是被一次ajax请求触发的,那么ajax返回后将得到一大堆用于显示错误的html代码。而一般
ajax调用都会约定自己的错误信息格式,所以后台php代码要么使用两种不同的报告错误的方式:一种给ajax调用请求使用,一种给普通的页面刷新使
用,要么使用统一的错误报告格式,在报告的时候判断一下这是一个ajax调用请求还是一个普通的页面刷新请求。
在php代码中检测是否ajax调用请求的方法是:
    if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
            strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                 // this is an ajax request
    }
这个方法来自于google搜索,据说只适用于jQuery发出的ajax请求。 ......
总记录数:2174; 总页数:363; 每页6 条; 首页 上一页 [2] [3] [4] [5] 6 [7] [8] [9] [10] [11]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号