易截截图软件、单文件、免安装、纯绿色、仅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代码

这是随机选择A0-A3四组数据中其中一组PHP代码:
<?php
$A[0]="QQ:<font color=ff32000>7161283</font>";
$A[1]="E_mail:<font color=ff32000>15018499772@139.com</font>";
$A[2]="手机:<font color=ff32000>15018499772</font>";
$A[3]="MSN:<font color=ff32000>chinaa ......

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 ......

在Fedora 12中安装Apache2+PHP5+MySQL(LAMP)

1.
前言
我使用的主机名为server1.example.com
,ip
地址是192.168.0.100
。这些设置可能与你想要的有所不同,所以你必须在适当的地方修改一下。
2
安装MySQL5
用下列命令安装MySQL

yum install mysql mysql-server
然后我们为MySQL
创建系统启动链接(这样的话,MySQL
就会随着系统启动而启动),并启动 ......

php单例模式


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