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

PHP的基础知识

看了些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();    //这样可以输出结果“1”。
?>
  注意:PHP可以在函数内部声明静态变量。用途同C语言中。
5,变量的变量,变量的函数
<?
//变量的变量
$a="hello";
$$a="world";
echo "$a $hello";    //将输出"hello world"
echo "$a ${$a}";    //同样将输出"hello world"
?>
<?
//变量的函数
function func_1(){
  print("test");
}
function fun($callback){
  $callback();
}
fun("func_1");    //这样将输出"test"
?>
6,PHP同时支持标量数组和关联数组,可以使用list()和array()来创建数组,数组下标从0开始。如:
<?
$a[0]="abc";
$a[1]="def";
$b["foo"]=13;
$a[]="hello";    //$a[2]="hello"
$a[]="world";    //$a[3]="world"
$name[]="jill";    //$name[0]="jill"
$name[]="jack";    //$name[1]="jack"
?>
7,关联参数传递(&的使用),两种方法。例:
<?
//方法一:
function foo(&$bar){
  $bar.=" and something extra";
}
$st


相关文档:

PHP字符串中的大括号

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

function getData($act){
$class = "Mode ......

Month of PHP Security Summary

it is 21th of May. The Month of PHP Security
(http://www.php-security.org) is still running and we have reached a
vulnerability count of 40 vulnerabilities, which is nearly as much as we
disclosed during the whole Month of PHP Bugs in 2007. However there are
11 more days until the end of May and ......

PHP通过session id 实现session共享和登录验证[转]

http://edu.codepub.com/2010/0131/20248.php
其实这个应该不算是疑难问题,就是php中用 sessionid得到session的值,因为的确很简单,只是可能大家平时用不到所以没有注意到罢了。
 
先说说,这个机制的用途吧,到现在为止战地知道这个机制有两个方面的用途:
其实这个应该不算是疑难问题,就是php中用 sessi ......

php单例模式


<?php  
    //单例模式的类Lock
  
    class
 Lock  
    {  
        //静态属性$instance
  
        ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号