首先是一个配置文件index.php
<?php define('THINK_PATH','ThinkPHP/');
define('APP_NAME','php100');
define('APP_PATH','.'); require(THINK_PATH."/ThinkPHP.php"); $App = new App();
$App->run();
?>
然后是在Lib文件夹下的一个控制器IndexAction.class.php
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action{
public function index(){
header("Content-Type:text/html; charset=utf-8");
echo "<div style='font-weight:normal;color:blue;float:left;width:345px;text-align:center;border:1px solid silver;background:#E8EFFF;padding:8px;font-size:14px;font-family:Tahoma'>^_^ Hello,欢迎使用<span style='font-weight:bold;color:red'>ThinkPHP</span></div>";
}
public function show(){
echo "123";
}
}
?>
然后再网页上输入http://localhost/php100/index.php 显示的是^_^ Hello,欢迎使用ThinkPHP那我要调用show方法 是在上面的网址上加?a=show,这时出现1.非法操作SHOW:如下
系统发生错误 您可以选择 [ 重试 ] [ 返回 ] 或者 [ 回到首页 ][ 错误信息 ]
非法操作show
就是这个问题
<?php define('THINK_PATH','ThinkPHP/');
define('APP_NAME','php100');
define('APP_PATH','.'); require(THINK_PATH."/ThinkPHP.php"); $App = new App();
$App->run();
?>
然后是在Lib文件夹下的一个控制器IndexAction.class.php
<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action{
public function index(){
header("Content-Type:text/html; charset=utf-8");
echo "<div style='font-weight:normal;color:blue;float:left;width:345px;text-align:center;border:1px solid silver;background:#E8EFFF;padding:8px;font-size:14px;font-family:Tahoma'>^_^ Hello,欢迎使用<span style='font-weight:bold;color:red'>ThinkPHP</span></div>";
}
public function show(){
echo "123";
}
}
?>
然后再网页上输入http://localhost/php100/index.php 显示的是^_^ Hello,欢迎使用ThinkPHP那我要调用show方法 是在上面的网址上加?a=show,这时出现1.非法操作SHOW:如下
系统发生错误 您可以选择 [ 重试 ] [ 返回 ] 或者 [ 回到首页 ][ 错误信息 ]
非法操作show
就是这个问题
http://localhost/php100/index.php/index/show
[11-10-08 18:41:10] () IndexAction->show()
[11-10-08 18:41:10] D:\wamp\www\php100\Runtime\~runtime.php (2) call_user_func(Array)
[11-10-08 18:41:10] D:\wamp\www\php100\Runtime\~runtime.php (2) App::exec()
[11-10-08 18:41:10] D:\wamp\www\php100\index.php (10) App::run()
public function show(){
return "123";
}
http://localhost/php100/index.php?a=Index&m=show 这个是TP中url的普通模式。
TRACE ]
[11-10-09 12:32:10] D:\wamp\www\php100\Runtime\~runtime.php (2) App::exec()
[11-10-09 12:32:10] D:\wamp\www\php100\index.php (10) App::run()
在IndexAction下新建一个方法
public function show()
{
echo 'hello world';
}第二步:
http://localhost/php100/index.php/index/show (如果你没修改任何配置的话,系统默认是PHTH_INFO模式,并且URL_MODEL 是2模式)
或者使用
http://localhost/php100/index.php?m=Index&a=show
// 0 (普通模式); 1 (PATHINFO 模式); 2 (REWRITE 模式);应该没错吧 还是同样的问题
http://localhost/php100/index.php?m=Index&a=show
m是模块名,a是方法名
/index/show
正确的运行应该是在新生成的lib文件夹中去修改,谢谢大家的帮忙了!!谢谢