1、先建好WAMP环境。本案例中用的是phpnow,你也可以用别的。简单安装完成目录大概长下图这样

2、函数是需要写在文里的,所以我们新建个文件,假设叫做myindex.php把文件放到WEB目录下

3、myindex.php内容为争犸禀淫<?php //这是一个php index函数function index(){echo '这是一个php index函数'稆糨孝汶;}index();//调用index函数

4、在浏览器地址栏输入http://localhost/myindex.php访问文件index函数被调用后打印出'这是一个php index函数';

5、前面是最简单的例子你也可以把index函数写在类里面,然后new一个实例去调用index函数争犸禀淫<?php class abc{//这是一个php index函数funct足毂忍珩ion index(){echo '这是一个abc类中的 index函数';}}$aa = new abc();$aa->index();

6、在浏览器地址栏输入http://localhost/myindex.php访问文件index函数被调用后打印出'这是一个abc类中的 index函数';
