php中的控制器类
我是php编程新手,我想问一个问题: 因此,我有3个php表单:php中的控制器类,php,http-referer,Php,Http Referer,我是php编程新手,我想问一个问题: 因此,我有3个php表单: insertworkerform.php inserttoolsform.php insertorderform.php 在这些文件中,我使用了标记 将用于控制这些文件, 所以我需要知道请求来自哪个文件,可能吗? 然后,当我知道哪个文件使用控制器类时,我将从与这3个文件请求相对应的另一个类调用该方法,这样可以吗?如果我理解正确,您有3个表单在三个单独的文件中?三个控制器都有一个控制器,所以您想知道如何传递发送它的文件 尝试:
- insertworkerform.php
- inserttoolsform.php
- insertorderform.php
标记
将用于控制这些文件,
所以我需要知道请求来自哪个文件,可能吗?
然后,当我知道哪个文件使用控制器类时,我将从与这3个文件请求相对应的另一个类调用该方法,这样可以吗?如果我理解正确,您有3个表单在三个单独的文件中?三个控制器都有一个控制器,所以您想知道如何传递发送它的文件 尝试:
将值替换为文档名称。Matthew Brown是对的,这里有另一种方法,仅用于学习目的 表格:
<!-- pass variable 'from' to the controller -->
<form action='class.controller.php?from=insertworkerform'>
class.controller.php
<?php
// example, if you want to store in database remember SQL Injection
$from = isset($_GET['from'])?
$_GET['from'] :
'I dont know which form called me';
// You can do what you want with the var $from
// like this
switch($from) {
case 'insertworkerform':
// bla bla
break;
case 'another_form':
// bl bla
break;
default:
// I dont know which form called me
}
<?php
// example, if you want to store in database remember SQL Injection
$from = isset($_GET['from'])?
$_GET['from'] :
'I dont know which form called me';
// You can do what you want with the var $from
// like this
switch($from) {
case 'insertworkerform':
// bla bla
break;
case 'another_form':
// bl bla
break;
default:
// I dont know which form called me
}